fix(inkless:switch): answer OffsetsForLeaderEpoch on in-sync followers while the switch is pending [KC-870] #904
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 513 lines diff across 6 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.373
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #904"
general
weight: 0.35
giuseppelillo
While the switch of a partition is pending, an in-sync follower rejects
OffsetsForLeaderEpoch, and a consumer that the metadata routing sends to that follower reads nothing until the controller commits the seal. With this change the in-sync follower answers from its local classic log.Problem
While
classicToDisklessStartOffsetis-2,InklessTopicMetadataTransformeradvertises an alive ISR member as the leader, a replica in the client's zone first. For many clients that replica is a follower.The controller bumps the leader epoch when it marks the switch pending. A consumer whose position has a leader epoch then validates the position with
OffsetsForLeaderEpochbefore it fetches again, and it sends the request to the advertised replica. InReplicaManager.lastOffsetForLeaderEpoch, the pending case answers only on the leader, so a follower returnsNOT_LEADER_OR_FOLLOWER. The consumer refreshes its metadata, gets the same follower, and retries until the seal commits.ListOffsetsalready lets an in-sync follower answer a client request in this state, and a consumer fetch works on the follower. Only the validation fails.Example before this change
On a 3-broker cluster in three zones, one follower stops without a controlled shutdown and stays in the ISR. The leader then holds one record above its high watermark, and the switch stays pending for 31 seconds. During that time, three consumers poll for 6 seconds from offset 5:
| Consumer | Records read |
| --- | --- |
| Routed to the in-sync follower, position with a leader epoch | 0 |
| Routed to the in-sync follower, position without a leader epoch | 15 |
| Routed to the leader, position with a leader epoch | 15 |
After the seal commits, the first consumer reads its records. On a healthy cluster the switch stays pending for 533 to 566 ms, measured over three switches.
Fix
While the switch is pending, a follower that is in the ISR answers
OffsetsForLeaderEpochfrom its local classic log. Its log holds every record below the leader's high watermark, and a consumer validates a position at or below that offset. The end offset that the follower returns is at or past that position.A follower caches only the leader epochs of the batches it appends. It has no end offset for a leader epoch higher than the last one in its log, such as the leader epoch of the switch. A consumer reads an undefined end offset as a truncation and resets its position. The follower returns
NOT_LEADER_OR_FOLLOWERfor such an epoch, as before this change.A replica outside the ISR still returns
NOT_LEADER_OR_FOLLOWER. The leader's answer doesn't change.Test plan
ReplicaManagerInklessTesthas three new tests for a follower of a pending partition: an in-sync follower answers, a follower outside the ISR returnsNOT_LEADER_OR_FOLLOWER, and an in-sync follower returnsNOT_LEADER_OR_FOLLOWERfor an epoch higher than the last one in its log. The first test fails without the change toReplicaManager. The class passes with 317 tests, andReplicaManagerTestpasses with 129 tests.InklessTopicTypeSwitcherClusterTesthas a new test,testConsumerRoutedToInSyncFollowerReadsWhileSwitchIsPending. It holds the switch pending as in the example, and a consumer in the follower's zone reads from its position while the switch is still pending. Without the change toReplicaManagerit fails withThe consumer read no record from the in-sync follower. The class passes with 10 tests.no-controlled-shutdowntag. For a tagged test, the setup setscontrolled.shutdown.enable=falseandbroker.session.timeout.ms=30000. The other tests keep the default values.:core:checkstyleMain,:core:checkstyleTest,:core:spotlessCheck, and:core:spotbugsMainpass.make valereports no alerts on the added lines.🤖 Generated with Claude Code
Assisted-by: Claude Fable 5.2