← Back to Pull requests

fix: stop replica top-up churn for completed bounded task groups #20387

Closed
unknown closed this pull request without merging on Sep 23, 2026 20:59 UTC
View on GitHub
unknown unknown commented on Sep 21, 2026 00:46 UTC
Author

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 with hasTaskGroupReachedBoundedEnd(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 whose startSequenceNumbers == endSequenceNumbers for 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 with replicas = 2 and a group whose metadata offsets have reached the bounded end must not create replacement replica tasks.

Note: I was unable to compile/run the test locally — master now targets Java 25 and my environment only has JDK 17/21. Relying on CI to validate.

<hr>

This PR has:

  • been self-reviewed.

  • added documentation for new or modified features or behaviors. (n/a — internal behavior fix)

  • a release note entry in the PR description. (n/a — bugfix)

  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • Diff: 300 lines (+225 / -75) across 3 files Reviewer: abhishekrb19 Review duration: 4093m
    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
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.1% (MEDIUM) · Higher = larger blast radius
    40.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.3% · Safe to merge
    17.3%
    Repository