← Back to Pull requests

fix(inkless:switch): advance a follower's high watermark to the seal when it applies the seal #866

Closed
unknown closed this pull request without merging on Nov 12, 2026 09:06 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 14:17 UTC
Author

A follower at the seal can miss the leader's last high watermark update, and consumers routed to that follower then stall one batch below the seal. test_switch_succeeds_with_degraded_network fails this way in run 41864719356 and run 40804888867.

Example

Partition P has replicas on brokers 1, 2, and 3. Broker 2 leads in epoch 0 with its log frozen at 100 while the switch is pending. Broker 1 is at 97, so the leader's high watermark is 97.

| Time | Where | What happens |
| --- | --- | --- |
| T0 | Broker 1 | Fetches at 97 in epoch 0. |
| T0+200 | Broker 2 | Answers with records 97 to 99 and high watermark 97. |
| T0+400 | Broker 1 | Appends to 100, keeps high watermark 97, fetches at 100 in epoch 0. |
| T0+600 | Broker 2 | Records broker 1 at 100 and advances its high watermark to 100. The fetch has no data, so it parks in purgatory for replica.fetch.wait.max.ms. The high watermark reached the frozen log end offset, so the leader sends InitDisklessLog. |
| T0+800 | Controller | Commits seal 100 and bumps the leader epoch to 1. |
| T0+1000 | Broker 1 | Applies the delta and restarts the fetcher for P in epoch 1. |
| T0+1100 | Broker 2 | The parked request times out. The response carries high watermark 100, and the fetch session records 100 as sent. |
| T0+1300 | Broker 1 | Drops the response, because the request was in epoch 0 and the fetch state is in epoch 1. Sends the next fetch in epoch 1. |
| T0+1500 | Broker 2 | Nothing about P changed since the session recorded high watermark 100, so the session leaves P out of the response. The sealed log never changes, so it leaves P out of every later response. |

Broker 1 keeps high watermark 97 until the next leader change. lastOffsetForLeaderEpoch and the ListOffsets router treat a local classic prefix below the seal as incomplete, so broker 1 answers NOT_LEADER_OR_FOLLOWER. Metadata routes consumers in its zone to it, and they retry until they time out.

Changes

A committed seal proves that every offset below it is committed: the leader requests the seal only after its high watermark reaches its frozen log end offset. The leader already restores a stale high watermark from that proof in maybeReconcileSwitchedLeader. The follower now does the same when it applies a committed seal with its log end offset at or past the seal, before it decides whether to schedule a catch-up fetch. A follower below the seal keeps its high watermark, because it still misses part of the prefix.

The fix doesn't touch the fetch session, so the follower still stays on the classic fetcher until the next leader change. That is the state every stalled partition is in today, and the partition is at the seal and in the ISR, so it's harmless.

PR #857 (KC-702) doesn't overlap with this change: its replica check compares leader epochs at any high watermark, and the failing test runs without remote storage, so its partitions never reach phase 2.

Testing

Unit tests in ReplicaManagerInklessTest cover a follower at the seal with a stale high watermark in phase 1 and phase 2, and a follower below the seal that keeps its high watermark. The promotion test stages the stale high watermark again after the follower delta, so it still exercises the leader-side restore. test_switch_succeeds_with_degraded_network needs repeated runs to confirm the acceptance criterion.

KC-722

Assisted-by: Claude Fable 5.1

[KC-722]: https://aiven.atlassian.net/browse/KC-722?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Diff: 470 lines (+352 / -118) across 5 files Reviewer: giuseppelillo Review duration: 4009m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 470 lines diff across 5 files
0.46
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.368
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #866"
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: 45.7% (MEDIUM) · Higher = larger blast radius
45.7%
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: 18% · Safe to merge
18%
Repository