fix: Kill task groups by partition, not groupId, when a pending completion group fails #20741
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 589 lines diff across 7 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.382
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #20741"
general
weight: 0.35
maytasm
Description
When a pending completion task group fails (no task succeeds within
completionTimeout, or all of its tasks fail),SeekableStreamSupervisor.checkPendingCompletionTasksresets the group's partitions, kills the actively reading task group with the same groupId, and stops every later pending completion task group in the same list.The groupId only identifies the same partitions while
taskCountis unchanged. After a task count change (for example, by the lag-based autoscaler), the reading task groups that actually started from the failed group's unpublished end offsets have other groupIds. They keep running, and their tasks fail to publish withThe new start metadata state[...] is ahead of the last committed end state[...]. The next rollover copies their end offsets intopartitionOffsets, so the gap is carried forward and the supervisor does not recover on its own. Resetting the supervisor recovers it, but skips the unpublished data.The same applies to the later pending completion task groups: after a task count change, the ones that started from the failed group's end offsets are not necessarily in the same list as the failed group, so they are not stopped.
We saw this in production when one task's segment push failed with a transient error at the same moment as an autoscaler scale action.
Stop the pending completion groups that started after a failed group
A pending completion task group is now stopped if it started reading any partition of a failed or stopped group from a later offset. This is the same condition that
isTaskReadyToPublishSegmentsuses to make a task wait for an older task group to publish, so these are exactly the groups whose publish depends on the failed group. The check covers all the pending completion lists, since after a task count change these groups can have any groupId. It is also applied to the groups that started after a stopped group.The groups are stopped before
onCompleted()is called on the failed group, so their publish waits resolve as not ready instead of being released. Otherwise, their publish would fail with the same error. Worse, if metadata storage has no committed offset for a shared partition yet, it would succeed and skip the failed group's data, since the metadata check ignores partitions that are not in the committed metadata.Groups that started reading the shared partitions before the failed group keep publishing. A later group in the same list is also no longer stopped if it shares only partitions on which the failed group read no data, since its publish does not depend on the failed group.
Kill the reading task groups by partition
The new
resetPartitionsAndKillReadingTaskGroupsresets the partitions of the failed and stopped task groups and kills every actively reading task group that:partitionGroupsbut is not reading it, such as a closed Kinesis shard whose end offset was never published. Otherwise, that partition would not be re-read until the task group rolls over.Reading task groups that started from the committed offsets are kept. For example, when a pending completion group published its offsets but timed out waiting for handoff, the readers that started from its end offsets keep running, whereas before, the reader with the same groupId was killed.
The reset and the kills now happen once, after all the pending completion groups are checked and the dependent ones are stopped, and before
onCompleted(). This way, the killed tasks' publish waits resolve as not ready before the completion listeners would let them publish.Release note
Fixed Kafka and Kinesis supervisors getting stuck in repeated task failures with "The new start metadata state ... is ahead of the last committed end state" after a publishing task group failed around a task count change, such as during autoscaling.
<hr>
##### Key changed/added classes in this PR
SeekableStreamSupervisorSeekableStreamSupervisorStateTest<hr>
This PR has: