feat(consumers): Auto-restart on single-partition lag - #8386
Open
sentry-junior[bot] wants to merge 8 commits into
Open
feat(consumers): Auto-restart on single-partition lag#8386sentry-junior[bot] wants to merge 8 commits into
sentry-junior[bot] wants to merge 8 commits into
Conversation
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>
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
marked this pull request as ready for review
August 23, 2026 23:25
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
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>
pbhandari
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Automatically resolve single-partition consumer lag by failing the pod healthcheck so Kubernetes restarts the member and Kafka rebalances.
Why
We saw one assigned partition fall far behind peers while offsets still moved slowly. Kafka does not rebalance in that case. GLOBAL subscription schedulers wait on the slow partition and shed stale work.
A hard "no commits at all" check is not enough. The observed failure was throughput collapse, not a hung poll loop.
What
Option-gated watchdog in the Snuba rust healthcheck (
--health-check-filerequired):consumer.partition_stall_timeout_secs> 0): partition has in-flight work and no commit progress past the timeout.consumer.partition_slow_ratioof the median sibling rate on this assignment while still receiving work. Default ratio is0.25. Set ratio to0for hard-stall only.Either failure stops touching the health file. The k8s liveness probe restarts the pod and Kafka reassigns the partitions.
Enabling the stall timeout auto-selects the Snuba healthcheck even if
--health-checkis stillarroyo.Naming / docs
experimental_healthcheck→consumer.commit_progress_healthcheck(consumer-level commit/idle progress).experimental_healthcheckas a legacy alias.docs/source/architecture/consumer.rst(Healthchecks).Enable
Via sentry-options (no deploy flag change if health-check file is already set):
consumer.partition_stall_timeout_secs: start around300consumer.partition_slow_ratio: default0.25(optional)consumer.commit_progress_healthcheck: optional consumer-level modeFollow-up outside this PR: rename the key in
getsentry/sentry-options-automator(experimental_healthcheck: false→consumer.commit_progress_healthcheck: false). Safe either way while the alias exists.Limits
Test plan
cargo test --lib strategies::healthcheck(9 tests, including legacy alias + relative slowdown)/tmp/health.txtRequested by PDPM.
--
View Junior Session in Sentry