fix: stop replica top-up churn for completed bounded task groups #20387
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 300 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.341
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #20387"
general
weight: 0.35
abhishekrb19
Description
In bounded (backfill) mode with
replicas > 1, the supervisor spins up an endless stream of tasks that complete instantly for partitions/groups that have already finished their backfill range.Root cause
SeekableStreamSupervisor.createNewTasks()has two places that create tasks:1. Task-group recreation (for groups no longer in
activelyReadingTaskGroups) — this path is already guarded withhasTaskGroupReachedBoundedEnd(groupId)and correctly skips completed bounded groups.2. Replica top-up ("make sure each task group has the desired number of replica tasks") — this path had no bounded-completion guard.
With
replicas > 1, once a group's committed offsets have reached the configured bounded end, replicas that finish and exit drop the group below the configured replica count. The top-up loop then keeps creating replacement replicas whose start offset is already at the bounded end (start == end), so each one reads nothing, completes immediately, drops the group below the replica count again, and re-triggers the top-up — churning tasks forever. Meanwhile genuinely lagging partitions continue reading normally.Observed as a flood of
index_kafka_*tasks whosestartSequenceNumbers == endSequenceNumbersfor an already-completed partition.Fix
Guard the replica top-up loop with the same
hasTaskGroupReachedBoundedEnd()check already used by the recreation path, so completed bounded groups are not topped up.This only affects bounded mode (
ioConfig.isBounded()); streaming supervisors are unchanged.Testing
Added
KafkaSupervisorTest#testBoundedStreamConfig_completedGroup_doesNotTopUpReplicas: a bounded supervisor withreplicas = 2and a group whose metadata offsets have reached the bounded end must not create replacement replica tasks.<hr>
This PR has: