Skip to content

feat(metrics): commit-time lag gauges for ack and source - #256

Open
iskakaushik wants to merge 1 commit into
mainfrom
kaushik/ack-commit-lag
Open

iskakaushik wants to merge 1 commit into
mainfrom
kaushik/ack-commit-lag

Conversation

@iskakaushik

@iskakaushik iskakaushik commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Replication lag from rate(source WAL) - rate(ack LSN) flips sign on bursty sources. This adds time-based gauges that need no rate window.

  • walshadow_emitter_ack_commit_timestamp_seconds: commit time (Unix seconds, f64) of the newest transaction ClickHouse has acked. Carried on the ack collector's contiguous frontier, so it advances exactly with walshadow_emitter_ack_lsn. Only final (publishing) seqs of a commit move it; aborts and bootstrap seqs carry no time and leave it unchanged.
  • walshadow_source_last_commit_timestamp_seconds: newest commit time the reorder stage has drained from the source.
  • Both are NaN until the first commit.

Lag reads as source_last_commit_ts - ack_commit_ts (stays correct when the source is idle) or time() - ack_commit_ts.

Notes: xact_time is the commit record's timestamp (PG epoch µs), converted to Unix seconds at scrape. The source gauge is taken at reorder's commit handling, not the pump, so it trails the pump by the decode queue.

Tests: frontier advance/gating and untimed/partial seqs in ack.rs; epoch conversion and NaN/value encoding in ops/metrics.rs. fmt, clippy -D warnings, lib/bin tests pass in Docker; only the known root-only cleanup_failure_keeps_pin_and_consumes_attempt fails.

@iskakaushik
iskakaushik force-pushed the kaushik/ack-commit-lag branch from 3d07545 to 05e2f1c Compare October 20, 2026 14:23
@iskakaushik
iskakaushik marked this pull request as ready for review October 20, 2026 15:50
@serprex
serprex force-pushed the kaushik/ack-commit-lag branch 2 times, most recently from 13e47b1 to 6d6a195 Compare October 23, 2026 20:45
Carry the commit record's xact_time with the emitter ack frontier and
export it as walshadow_emitter_ack_commit_timestamp_seconds, plus the
newest drained commit as walshadow_source_last_commit_timestamp_seconds.
Both are Unix seconds, NaN until the first commit, so replication lag is
a plain subtraction with no PromQL rate window.
@serprex
serprex force-pushed the kaushik/ack-commit-lag branch from 6d6a195 to dc5def9 Compare October 23, 2026 20:51
@serprex
serprex requested a review from harshil-goel October 23, 2026 21:25
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