← Back to Pull requests

fix(inkless:switch): abort open transactions only on the leader at the switch [KC-753] #874

Closed
unknown closed this pull request without merging on Nov 17, 2026 14:51 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 16:13 UTC
Author

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 the ABORT markers with appendAsLeader and didn't check that the broker leads the partition. The follower path calls makeFollower and then seal(), so a follower with the open transaction in its log wrote its own marker.

  • The leader path called seal() before makeLeader, so the leader wrote its marker in the previous leader epoch.

  • KafkaApis answered WriteTxnMarkers for a diskless topic with INVALID_TOPIC_EXCEPTION. TransactionMarkerRequestCompletionHandler has no case for that error and throws IllegalStateException. The transaction stayed in PrepareCommit with 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 whether seal() ran in the same call sequence, so a replica that sealed as a follower aborts when it becomes the leader.

  • After it appends the markers, the leader advances the high watermark itself. With the leader as the only ISR member, no follower fetch advances it, and InitDisklessLogManager waits for HW == LEO.

  • ReplicaManager.applyLocalLeadersDelta calls the abort after makeLeader, and only while the switch is pending. After the controller commits the seal offset, the leader doesn't append to the classic prefix.

  • A leader that loads a pending switch with no Partition yet, such as after a restart, registers the partition with InitDisklessLogManager. Before, that branch sealed the partition and nothing proposed the seal offset until the next leader epoch.

  • ReplicaManager.applyLocalFollowersDelta only seals. The follower replicates the leader's markers.

  • KafkaApis answers WriteTxnMarkers for a diskless topic with UNSUPPORTED_FOR_MESSAGE_FORMAT and 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 ABORT markers without the coordinator. If the producer commits a transaction that was open at the switch, the commit succeeds and the transaction reaches CompleteCommit, but the switched partition keeps its ABORT marker, and a read_committed consumer gets no records from it. The cluster test asserts this behavior. CLASSIC_TO_DISKLESS_SWITCH.md has a new section, "Open transactions at the switch", that describes it.

    Testing

  • PartitionTest has 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.testApplyDeltaRegistersPendingSwitchLeaderWithoutExistingPartition applies a pending switch to a broker with a local log and no Partition, and checks that the leader seals and registers. Without the registration, it fails.

  • KafkaApisTest.testHandleWriteTxnMarkersRequestWithInklessTopic expects UNSUPPORTED_FOR_MESSAGE_FORMAT.

  • InklessTopicTypeSwitcherClusterTest.testTransactionOpenAtSwitchIsAbortedAndCompletes writes 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 reaches CompleteCommit with no pending partitions, that the transactional.id commits a second transaction on a classic topic, and that a read_committed consumer gets no records from the switched partition.

  • With the fix reverted, the cluster test fails because the marker is in the pre-switch leader epoch. With only the KafkaApis change reverted, it fails with the transaction in PrepareCommit. 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, and InklessConsolidatedDisklessTopicsTest pass, along with :core:checkstyleTest, :core:spotlessCheck, and make vale.
  • KC-753

    🤖 Generated with Claude Code

    Assisted-by: Claude Fable 5.2

    [KC-753]: https://aiven.atlassian.net/browse/KC-753?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: giuseppelillo Review duration: 1358m
    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
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository