← Back to Pull requests

fix(inkless:switch): skip ISR expansion while a phase 1 leader's log ends below the seal [KC-773] #880

Closed
unknown closed this pull request without merging on Nov 18, 2026 13:59 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 10:19 UTC
Author

ClassicToDisklessSwitchLastKnownLeaderClusterTest (loseTail=true) fails intermittently in CI. The cause is a race in the broker, not in the test.

After a last-known-leader election in phase 1 of the classic-to-diskless switch, the restarted leader runs makeLeader and then fences itself when its log ends below the committed seal. A follower fetch between those two steps expands the ISR. The controller then records a full ISR and a recovered leader for a partition that the leader marks offline. When the operator lowers the seal and restarts the leader, the controller elects another ISR member, and the test times out waiting for the restarted broker to lead.

This contradicts [CLASSIC_TO_DISKLESS_SWITCH.md](docs/inkless/CLASSIC_TO_DISKLESS_SWITCH.md), which says the controller keeps an ISR of one after this election.

Partition.isFollowerInSync now returns false while the leader's log end offset is below the committed seal. The check reads replicationStopOffset() directly instead of the sealed-gated value, because seal() runs after makeLeader on a restarted leader.

Evidence

In the CI artifact for the failure on e3913e8c10 (run 44107792176), the leader is broker 2. When it shuts down in reSeal, broker 0 takes over, which only an ISR member can do.

To reproduce it locally, I added a 1.5-second sleep between makeLeader and maybeReconcileSwitchedLeader in ReplicaManager.applyLocalLeadersDelta. The test then failed on the first run with the ticket's signature: leader=2, isr=[0,1,2], leaderRecoveryState=RECOVERED. The logs of the failing run show:

The election sets the ISR to [1] and the state to RECOVERING.
Broker 1 logs ISR updated to 1,2 and then ISR updated to 2,1,0 before it marks the partition offline.

Testing

PartitionTest.testIsrNotExpandedWhileLeaderLogEndsBelowSeal fails without the change (expected: <0> but was: <1>) and passes with it. All 106 tests in PartitionTest pass.
With the same 1.5-second sleep and the change, ClassicToDisklessSwitchLastKnownLeaderClusterTest passes both cases. The sleep isn't part of this PR.

  • Without the sleep, 10 consecutive local runs of the cluster test passed before the change, so the local runs don't show the race on their own.
  • Fixes KC-773.

    🤖 Generated with Claude Code

    Diff: 293 lines (+219 / -74) across 3 files Reviewer: viktorsomogyi Review duration: 220m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 293 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%
    60%
    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.340
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #880"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 39.9% (MEDIUM) · Higher = larger blast radius
    39.9%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 15.8% · Safe to merge
    15.8%
    Repository