Skip to content

feat(consumers): Auto-restart on single-partition lag - #8386

Merged
phacops merged 16 commits into
masterfrom
feat/partition-stall-watchdog
Aug 31, 2026
Merged

feat(consumers): Auto-restart on single-partition lag#8386
phacops merged 16 commits into
masterfrom
feat/partition-stall-watchdog

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

--health-check partition-stall fails the Kubernetes health file when any assigned partition has in-flight work with no commit progress for consumer.partition_stall_timeout_secs (default 300s; 0 disables detection). The pod restarts and Kafka rebalances.

--health-check selects one file owner:

  • arroyo (default): touch on every successful poll
  • commit-progress: touch on commit or idle (consumer-level; one stuck partition can stay healthy if siblings still commit)
  • partition-stall: per-partition stall as above

Relative throughput comparison was dropped. During backlog recovery, librdkafka can starve sibling partitions, which would look like slowdown and force extra rebalances. This check only trips on stuck in-flight work, not on partitions that are not being delivered.

experimental_healthcheck and --health-check snuba are gone. Python consumers are unchanged (arroyo poll-only file touch). Requires --health-check-file.

Requested by PDPM.

--

View Junior Session in Sentry

sentry-junior Bot and others added 3 commits August 23, 2026 20:55
Add an option-gated watchdog in the Snuba rust healthcheck that tracks
submit vs commit progress per partition. When a partition has in-flight
work without commit progress past the timeout, stop touching the health
file so the k8s liveness probe restarts the pod and Kafka rebalances.

Co-Authored-By: PDPM <pierre.massat@sentry.io>
Extend the stall watchdog so it also fails health when one assigned
partition's commit rate falls far below the median sibling rate while
still receiving work. That covers the single-partition lag case where
offsets still move slowly and a hard commit stall never fires.

Co-Authored-By: PDPM <pierre.massat@sentry.io>

Co-Authored-By: PDPM <pierre.massat@sentry.io>
@sentry-junior sentry-junior Bot changed the title feat(consumers): Restart on per-partition commit stall feat(consumers): Auto-restart on single-partition lag Aug 23, 2026
getsantry Bot and others added 3 commits August 23, 2026 21:28
Rename experimental_healthcheck to consumer.commit_progress_healthcheck
so the name matches consumer-level commit/idle progress checks. Keep the
old key as a legacy alias. Document strategy and progress modes in the
consumer architecture docs.

Co-Authored-By: PDPM <pierre.massat@sentry.io>
@phacops
phacops marked this pull request as ready for review August 23, 2026 23:25
@phacops
phacops requested a review from a team as a code owner August 23, 2026 23:25
Comment thread rust_snuba/src/strategies/healthcheck.rs Outdated
Compare each partition to the median of the other active partitions on
the assignment. An inclusive median diluted the slow partition on small
assignments, so the default 0.25 ratio missed the two-partition collapse
case.

Co-Authored-By: PDPM <pierre.massat@sentry.io>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9abdb3a. Configure here.

Comment thread rust_snuba/src/strategies/healthcheck.rs Outdated
Keep leave-one-out sibling medians for the ratio comparison, but gate the
whole assignment on an inclusive median quiet floor so one hot partition
cannot fail mostly-quiet peers. Also satisfy clippy::question_mark on the
slow-ratio option helper.

Co-Authored-By: PDPM <pierre.massat@sentry.io>

@onewland onewland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a bad idea without more safeguards. It has potential to cause a negative feedback loop.

We've seen in backlog situations before that when a consumer is successfully processing multiple partitions of a topic (after a period of not-processing) where all partitions are quite behind that librdkafa and the broker will queue messages for processing based on partition ordering, meaning some partitions will not make progress for a while until the "front-most" partition drops below a certain threshold where the buffer will receive messages from a wider set. If that happens with this change enabled, you'll force more rebalancing and slow down recovery; a similar pattern to OOMing when we hit a backlog

The key is unused in sentry-options-automator, so keep only consumer.commit_progress_healthcheck.
Comment thread rust_snuba/src/strategies/healthcheck.rs Outdated
Comment thread rust_snuba/src/strategies/healthcheck.rs Outdated
Select one file owner with --health-check (arroyo, commit-progress, partition-stall). Drop option-gated modes and relative slowdown. consumer.partition_stall_timeout_secs is only the stall timeout.
Nothing in ops or tests passed --health-check snuba; keep only arroyo, commit-progress, and partition-stall.
Comment thread snuba/cli/accepted_outcomes_consumer.py
Drop redundant health-file state, saturate idle-poll counters, and use checked SystemTime adds so long-running consumers cannot panic on overflow.
Track stable there for CI, Docker, and local cargo. Drop the extra rustup install step and Makefile +stable fmt override. Satisfy current-stable clippy.
The CLI already advertised --health-check and --health-check-file, but the Rust factory ignored them. Wrap the pipeline with the same strategies as rust-consumer so Kubernetes probes actually work.
@phacops

phacops commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@onewland relative throughput comparison is gone for exactly that reason.

--health-check partition-stall now only fails the health file when a partition has in-flight work (a submit with no later commit) for consumer.partition_stall_timeout_secs (default 300s). Idle / not-yet-delivered partitions stay healthy.

During backlog recovery, librdkafka starving siblings should not trip this: those partitions never get submits, so they are not in-flight. A restart still only helps if the owning member is the problem.

--health-check arroyo remains the default.

Touching ci.yml runs validate-devservices-config, which currently fails in teardown (empty CODEROOT). Keep the toolchain pin in rust-toolchain.toml instead.
validate-devservices-config is gated on ci.yml changes and currently fails in teardown. Drop the workflow edit so that job does not run.
@phacops
phacops merged commit 922770c into master Aug 31, 2026
68 checks passed
@phacops
phacops deleted the feat/partition-stall-watchdog branch August 31, 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.

3 participants