fix(inkless:switch): abort open transactions only on the leader at the switch [KC-753] #874
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 #874"
general
weight: 0.35
giuseppelillo
Diskless topics don't support transactions. A transaction can still be open on a partition when the switch starts: it added the partition and wrote to it while the topic was classic.
Partition.seal()aborted such a transaction on every replica, and the transaction coordinator couldn't complete it.Problem
seal()appended theABORTmarkers withappendAsLeaderand didn't check that the broker leads the partition. The follower path callsmakeFollowerand thenseal(), so a follower with the open transaction in its log wrote its own marker.seal()beforemakeLeader, so the leader wrote its marker in the previous leader epoch.KafkaApisansweredWriteTxnMarkersfor a diskless topic withINVALID_TOPIC_EXCEPTION.TransactionMarkerRequestCompletionHandlerhas no case for that error and throwsIllegalStateException. The transaction stayed inPrepareCommitwith the partition still pending.Fix
seal()sets the sealed flag and rolls the active segment. It doesn't abort.Partition.abortOngoingTransactionsAsSealedLeader()appends the markers and rolls the active segment again. It does nothing on a follower. It doesn't depend on whetherseal()ran in the same call sequence, so a replica that sealed as a follower aborts when it becomes the leader.InitDisklessLogManagerwaits forHW == LEO.ReplicaManager.applyLocalLeadersDeltacalls the abort aftermakeLeader, and only while the switch is pending. After the controller commits the seal offset, the leader doesn't append to the classic prefix.Partitionyet, such as after a restart, registers the partition withInitDisklessLogManager. Before, that branch sealed the partition and nothing proposed the seal offset until the next leader epoch.ReplicaManager.applyLocalFollowersDeltaonly seals. The follower replicates the leader's markers.KafkaApisanswersWriteTxnMarkersfor a diskless topic withUNSUPPORTED_FOR_MESSAGE_FORMATand logs the dropped marker. The coordinator handles that error by removing the partition from the transaction, so the upstream handler is unchanged.Known limitation
This change doesn't make the leader and the coordinator agree on the outcome of a transaction that the producer commits after the switch. The leader writes the
ABORTmarkers without the coordinator. If the producer commits a transaction that was open at the switch, the commit succeeds and the transaction reachesCompleteCommit, but the switched partition keeps itsABORTmarker, and aread_committedconsumer gets no records from it. The cluster test asserts this behavior.CLASSIC_TO_DISKLESS_SWITCH.mdhas a new section, "Open transactions at the switch", that describes it.Testing
PartitionTesthas four new tests: a sealed follower doesn't append a marker, a sealed follower that becomes the leader aborts in the new leader epoch and leaves the marker in a closed segment, the abort advances the high watermark when the leader is the only ISR member, and the abort throws on a partition that isn't sealed. The existing seal tests call the abort explicitly.ReplicaManagerInklessTest.testApplyDeltaRegistersPendingSwitchLeaderWithoutExistingPartitionapplies a pending switch to a broker with a local log and noPartition, and checks that the leader seals and registers. Without the registration, it fails.KafkaApisTest.testHandleWriteTxnMarkersRequestWithInklessTopicexpectsUNSUPPORTED_FOR_MESSAGE_FORMAT.InklessTopicTypeSwitcherClusterTest.testTransactionOpenAtSwitchIsAbortedAndCompleteswrites five records in a transaction, switches the topic, and commits. It checks that the seal offset is the five records plus one marker, that every replica has the marker in the same leader epoch and past the pre-switch epoch, that the transaction reachesCompleteCommitwith no pending partitions, that thetransactional.idcommits a second transaction on a classic topic, and that aread_committedconsumer gets no records from the switched partition.KafkaApischange reverted, it fails with the transaction inPrepareCommit. Without the high watermark change, the new only-ISR-member test fails with the high watermark one offset below the log end offset.PartitionTest,KafkaApisTest,ReplicaManagerInklessTest,InitDisklessLogManagerTest,DisklessSwitchFlowTest,InklessTopicTypeSwitcherClusterTest,ClassicToDisklessSwitchLastKnownLeaderClusterTest, andInklessConsolidatedDisklessTopicsTestpass, along with:core:checkstyleTest,:core:spotlessCheck, andmake vale.KC-753
🤖 Generated with Claude Code
Assisted-by: Claude Fable 5.2
[KC-753]: https://aiven.atlassian.net/browse/KC-753?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ