fix(inkless:switch): advance a follower's high watermark to the seal when it applies the seal #866
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
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.368
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #866"
general
weight: 0.35
giuseppelillo
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_networkfails 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 sendsInitDisklessLog. || 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.
lastOffsetForLeaderEpochand theListOffsetsrouter treat a local classic prefix below the seal as incomplete, so broker 1 answersNOT_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
ReplicaManagerInklessTestcover 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_networkneeds 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