Skip to content

feat(postgres): emit source replication log space metrics for Postgres - #4640

Open
dtunikov wants to merge 4 commits into
mainfrom
dbi-960-source-log-disk-space-metrics
Open

feat(postgres): emit source replication log space metrics for Postgres#4640
dtunikov wants to merge 4 commits into
mainfrom
dbi-960-source-log-disk-space-metrics

Conversation

@dtunikov

@dtunikov dtunikov commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds PostgreSQL replication-slot WAL-capacity metrics so we can alert before a source invalidates a slot because retained WAL has reached its configured limit.

  • source_log_space_used: WAL bytes retained for the slot.
  • source_log_space_limit: effective retention cap, derived from max_slot_wal_keep_size and wal_keep_size; omitted when retention is unbounded.
  • source_log_space_safe_ratio: remaining safe WAL headroom divided by the effective retention cap.

safe_wal_size is already emitted as a raw byte metric. The normalized safe ratio makes alerting straightforward: alert when source_log_space_safe_ratio < 0.1. A value at or below zero means the configured limit has been reached or exceeded.

The safe ratio is emitted only when PostgreSQL provides safe_wal_size and a finite retention cap is configured (PostgreSQL 13+). Its absence means the source has no finite slot-WAL cap or does not support safe_wal_size, not that the slot is healthy.

Validation

  • go test ./otel_metrics
  • go test ./connectors/postgres -run '^TestWalRetentionSettingsLimitBytes$' -count=1

Comment thread flow/connectors/mysql/log_space.go Fixed
Comment thread flow/connectors/mysql/log_space.go Fixed
@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: Not a flaky test: the flow-worker container crashed with exit code 2 (Go unrecovered panic) ~13 minutes into the run while all databases stayed healthy, stalling every mirror and cascading into a 20-minute package timeout with ~600 downstream STATUS_SETUP/STATUS_SNAPSHOT failures — the worker crash needs to be diagnosed from the artifact's docker-flow-worker.log, with the PR's new worker-side disk-space metrics collection as the prime suspect.
Confidence: 0.7

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@dtunikov dtunikov changed the title Emit source replication log space metrics for Postgres and MySQL wip: Emit source replication log space metrics for Postgres and MySQL Jul 29, 2026
Comment thread flow/connectors/mysql/log_space.go Fixed
Comment thread flow/connectors/mysql/log_space.go Fixed
@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: All 11 subtests of TestParseReplicationOffsetText fail deterministically in 0.00s across both matrix jobs because the PR changed parsedReplicationOffset.mechanism from string to protos.MySqlReplicationMechanism while the test at replication_mechanism_test.go:44 still compares it against wantMechanism().String(), causing a testify type mismatch.
Confidence: 0.96

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@dtunikov
dtunikov force-pushed the dbi-960-source-log-disk-space-metrics branch from 5c86331 to 4d5c28e Compare July 29, 2026 20:28
@dtunikov dtunikov changed the title wip: Emit source replication log space metrics for Postgres and MySQL feat(postgres): emit source replication log space metrics for Postgres Jul 29, 2026
@dtunikov
dtunikov marked this pull request as ready for review July 29, 2026 20:53
@dtunikov
dtunikov requested a review from a team as a code owner July 29, 2026 20:53
@claude

claude Bot commented Jul 29, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants