Skip to content

feat(ingestion-consumer): count gap walks and clear stale confirmation lag - #95873

Merged
trunk-io[bot] merged 2 commits into
masterfrom
pl/ingestion/ledger-gap-walks
Sep 7, 2026
Merged

feat(ingestion-consumer): count gap walks and clear stale confirmation lag#95873
trunk-io[bot] merged 2 commits into
masterfrom
pl/ingestion/ledger-gap-walks

Conversation

@pl

@pl pl commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Problem

Operators reading the offset ledger dashboard see two things that are not true now that the ledger frontier owns commits (#91766).

  • A partition a pod no longer owns keeps showing a constant nonzero commit confirmation lag. The gauge is refreshed only from OffsetFetch results for assigned partitions. A partition revoked while a commit was still unconfirmed keeps its last value for the life of the process, and a pod that held it for one incremental assign dominates the per-partition max for days.
  • Nothing records when a frontier commit steps past an offset Kafka never delivered. The ledger fills such an offset with pre-completed filler and the frontier walks over it. The commit sentinel compares a batch's first offset with the previous commit, so a gap inside a batch's span never reaches it.

Changes

  • The confirmation lag gauge drops to zero for a partition when the pod loses it. CommitSentinel::forget_partitions zeroes it for every revoked partition that had a commit attempted.
  • A new counter, kafka_consumer_ledger_gap_offsets_total by topic and partition, counts undelivered offsets a frontier commit walked over. The topic ledger emits it when a take drains filler; a take without gaps emits nothing.
  • Mechanical: the partition ledger marks filler slots as undelivered and TakenFrontier gains gap_offset_count.

How did you test this code?

  • gap_filler_carries_no_charge_and_the_frontier_walks_over_it now asserts the gap count.
  • New a_take_counts_each_gap_offset_once catches a take that counts drained filler twice, or counts filler the frontier did not reach.
  • The gauge reset has no unit test: the sentinel emits through the global metrics recorder, which the existing tests do not capture. Not verified in a running consumer.
  • Ran clippy and the unit tests for common-kafka-consumer and ingestion-consumer inside flox.

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code. Skills invoked: /writing-pr-descriptions. Both gaps surfaced while reviewing the first days of commit mode in production: a stale per-partition lag gauge on a pod that briefly held partitions during an incremental assign, and the sentinel gap counter reading zero once frontier commits replaced per-batch commits. Searched open ledger PRs; none covers either.

@pl pl self-assigned this Sep 7, 2026
@trunk-io

trunk-io Bot commented Sep 7, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

Trunk lane — non-backend lane

This PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes.

@trunk-io

trunk-io Bot commented Sep 7, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

pl added 2 commits September 7, 2026 09:05
The ledger fills an undelivered offset with pre-completed filler, so a
frontier commit steps past it silently. With the frontier owning commits
the commit sentinel no longer reports these walks as gaps, so nothing
records that a commit skipped an offset Kafka never delivered.

The partition ledger now marks filler as undelivered and reports how many
filler offsets a take drained. The topic ledger counts them at take as
kafka_consumer_ledger_gap_offsets_total by topic and partition. A take
without gaps emits nothing.
…voke

The gauge is refreshed from OffsetFetch results, which only cover assigned
partitions. A partition revoked while a commit was still unconfirmed kept
reporting that lag for the life of the process, so a pod that held a
partition for one incremental assign showed a constant nonzero lag for
days and dominated the per-partition max on the dashboard.

forget_partitions now sets the gauge to zero for every revoked partition
that had a commit attempted.
@pl
pl force-pushed the pl/ingestion/ledger-gap-walks branch from 16f27f9 to 9875461 Compare September 7, 2026 07:06
@pl
pl marked this pull request as ready for review September 7, 2026 07:08
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team September 7, 2026 07:09
@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(ingestion-consumer): zero the commit..." | Re-trigger Greptile

@trunk-io
trunk-io Bot merged commit 279b205 into master Sep 7, 2026
301 checks passed
@trunk-io
trunk-io Bot deleted the pl/ingestion/ledger-gap-walks branch September 7, 2026 08:51
@deployment-status-posthog

deployment-status-posthog Bot commented Sep 7, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-09-07 09:14 UTC Run
prod-us ✅ Deployed 2026-09-07 09:26 UTC Run
prod-eu ✅ Deployed 2026-09-07 09:27 UTC Run

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