fix(inkless:switch): return a diskless leader epoch with a diskless offset in ListOffsets [KC-865] #900
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 436 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.364
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #900"
general
weight: 0.35
viktorsomogyi
A consumer that takes its position and leader epoch from
ListOffsetson a switched partition seeks back to the seal the next time it validates that position. With this change,ListOffsetsreturns an epoch that keeps the position.Problem
ListOffsetsreturns leader epoch 0 with every diskless offset, becauseFetchOffsetHandlersets a placeholder epoch on each control-plane result. On a switched partition,ReplicaManager.lastOffsetForLeaderEpochtreats an epoch belowinitialDisklessLeaderEpochas a classic epoch and answers with an end offset at or below the seal. A client that keeps the epoch of theListOffsetsresponse then sees a truncation when it validates its position.A consumer fetch doesn't have this problem:
ReplicaManager.stampDisklessLeaderEpochsetsdisklessLeaderEpochon the batches that a switched partition serves from diskless storage. The Java consumer drops the epoch of a reset position (OffsetFetcherUtils.resetPositionIfNeeded), so it isn't affected on a reset. Other clients keep the epoch:ListOffsetsresponse to the fetch position (rd_kafka_toppar_handle_Offset), andrd_kafka_offset_validatesends it when metadata shows a higher leader epoch.seek(TopicPartition, OffsetAndMetadata)with the epoch fromoffsetsForTimesorAdmin.listOffsets.Example before this change
On a 3-broker cluster, a partition is sealed at offset 20 and has 30 diskless records:
Admin.listOffsets(latest)returns offset 50 withleaderEpoch=0. A Java consumer that seeks to offset 50 with that epoch reads its first record at offset 20.Fix
DisklessFetchOffsetRouterreplaces the placeholder on a switched partition:disklessLeaderEpoch, the epoch that a consumer fetch carries for the same offsets.OffsetsForLeaderEpochanswers that epoch with the diskless log end offset, so the client keeps its position.Born-diskless partitions keep the placeholder, and a result from the local log keeps the epoch of the local record.
Test plan
DisklessFetchOffsetRouterTestcovers LATEST, MAX_TIMESTAMP, EARLIEST, and a timestamp lookup on both sides of the seal, in phase 1 and phase 2, and a partition with a seal of 0.ReplicaManagerInklessTest.testFetchOffsetLatestOnSwitchedPartitionReturnsAnEpochThatKeepsThePositionsendsListOffsetsand validates the returned epoch withOffsetsForLeaderEpoch.InklessTopicTypeSwitcherClusterTest.testConsumerKeepsAPositionFromListOffsetsOnASwitchedPartitionruns on 3 brokers. A consumer seeks to the offset and epoch thatListOffsetsreturns, in phase 1 and in phase 2, and starts at that offset.DisklessFetchOffsetRouter, the new router tests, theReplicaManagerInklessTesttest, and the cluster test fail.DisklessFetchOffsetRouterTestpasses with 65 tests.:core:checkstyleMain,:core:checkstyleTest, and:core:spotbugsMainpass.make valereports no alerts on the added lines.🤖 Generated with Claude Code