fix(inkless:switch): validate the classic epoch history of replicas admitted in phase 2 [KC-702] #851
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #851"
general
weight: 0.35
giuseppelillo
In phase 2 of the classic-to-diskless switch, the controller adds every live replica to the ISR without checking its local copy of the classic prefix, and any replica can lead. A replica can hold records below the seal that the partition doesn't hold. It led an older leader epoch and wrote records that the next leader didn't have, or an unclean leader election before the switch discarded records below its high watermark. Forced deletion keeps the leader epoch cache of that replica, and the remote log manager uses it to compute the highest offset in remote storage and to pick remote segments. On that replica, a tiered read below the seal fails with
OFFSET_OUT_OF_RANGE, and the consumer resets its offset. On an idle topic, the highest offset in remote storage also stays below the seal, so forced deletion never completes.Changes
seal - 1inSetClassicPrefixInRemoteStorage. The controller stores it with the flag as tag104(lastClassicLeaderEpoch) and drops it when the switch is undone. The value is-1if the leader's log doesn't contain a record below the seal.seal - 1to the recorded epoch, the replica truncates its log fully at the log start offset. Each epoch has one leader, so a matching epoch proves that the records below the seal are the committed ones, at any high watermark. After the truncation, the log ends below the seal, like the log of a replica that lost its local data. The existing recovery rebuilds the log, the leader epoch cache, and the producer state from remote storage. A follower that keeps its leader epoch when phase 2 starts was an ISR member or ran the classic fetcher in phase 1, so the leader's divergence check covers it.DisklessLeaderEndPointreturns the recorded epoch instead of the queried one. That epoch has no records, andTierStateMachinelooks up the remote segment atseal - 1by the returned epoch. Remote storage can also hold a segment atseal - 1from a discarded epoch, so the endpoint doesn't take the epoch from remote storage.fetchEarliestLocalOffsetapplies the same bound. The control plane keeps the WAL start at the classic log start until the first prune moves it to the seal. Without the bound, a leader that lost its local log before that prune reads the first diskless batch at offset 0, and its local log hides the remote prefix.CLASSIC_TO_DISKLESS_SWITCH.mddescribes the recorded epoch and the replica check.DISKLESS_CONSOLIDATION.mddescribes the epoch that the endpoint returns, the first-prune bound, and the retention guard.A leader uploads only segments below its last stable offset. Unclean leader election is off before the switch and blocked in phase 1, so the classic prefix in remote storage contains only committed records.
inkless-release-0.50has theSetClassicPrefixInRemoteStorageRPC and tag103, but its brokers don't send the flag request. So no released partition is in phase 2 without the recorded epoch.Limitations
lastClassicLeaderEpochis-1, brokers skip the check. Besides an empty prefix, that covers a flag that a controller or leader without this change set, for example during a rolling upgrade.TierStateMachinerebuild, like a leader that lost its local log. A gap in that rebuild affects both cases.Testing
testSwitchedLeaderInPhaseTwoChecksLastClassicLeaderEpochelects a leader that wrote[7, 10)in epoch 1, with its high watermark at 7 and at the seal. If the recorded epoch is 0, the leader truncates fully, stays online, and starts consolidation at 0. If it's 1, the leader keeps its log and starts consolidation at the seal.testSwitchedConsolidatingFollowerInPhaseTwoChecksLastClassicLeaderEpochruns a follower at the seal with its high watermark at the seal. With a matching epoch, it consolidates from the seal. With a divergent epoch, it truncates fully and fetches from 0 on the classic fetcher.testTierStateMachineLooksUpLastClassicSegmentByRecordedEpochrunsTierStateMachineagainstDisklessLeaderEndPointwhile a segment from a discarded epoch also coversseal - 1. The lookup uses the recorded epoch and never the discarded one.testFetchEpochEndOffsetsBelowDisklessEpochReturnsLastClassicLeaderEpochchecks the epoch that the endpoint returns for a query above, at, and below the recorded epoch, and without one.PartitionRegistrationTest,PartitionChangeBuilderTest,ReplicationControlManagerInklessTest, andInitDisklessLogManagerTestcover the field from the leader's request through the controller record, replay, merge, and switch undo.testFetchAtSealBeforeFirstPruneReadsTheWal,testFetchSignalsOffsetMovedBelowSealBeforeFirstPrune,testFetchRetriesBelowSealBeforeFirstPruneWithoutRemoteCoverage, andtestFetchEarliestLocalOffsetBeforeFirstPruneUsesSealAndDisklessEpochcover the first-prune bound.testEpochCacheCleanupKeepsConsolidatingSegmentsFromCrossTierStartandtestFullTruncationBeforePromotionKeepsRemotePrefixUntilRebuildcover the retention guard. The second test runs on a real log, before and after the rebuild.ReplicaManagerInklessTest,ReplicaManagerTest,ReplicaFetcherThreadTest,DisklessSwitchInvariantsTest,DisklessSwitchFlowTest,InitDisklessLogManagerTest,InklessMetadataViewTest,DisklessLeaderEndPointTest,ConsolidationFetcherThreadTest,RemoteLogManagerTest,QuorumControllerTest,RequestResponseTest, andMessageTestpass, along with the metadata tests in the preceding item.checkstyleMain,checkstyleTest,spotbugsMain, andspotlessCheckpass onclients,metadata, andcore. The full./gradlew check -x test -x generateJooqClassesdidn't run locally.tests/kafkatest/tests/inkless/didn't run on this change.make valedoesn't report any alerts.Assisted-by: Claude Opus 5.5