KAFKA-20357: Persist lastProducerEpoch fields for the transaction log.#22096
Open
chickenchickenlove wants to merge 1 commit intoapache:trunkfrom
Open
KAFKA-20357: Persist lastProducerEpoch fields for the transaction log.#22096chickenchickenlove wants to merge 1 commit intoapache:trunkfrom
chickenchickenlove wants to merge 1 commit intoapache:trunkfrom
Conversation
|
A label of 'needs-attention' was automatically added to this PR in order to raise the |
Contributor
Author
|
@jolshan Hi! |
|
A label of 'needs-attention' was automatically added to this PR in order to raise the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change follows up on KAFKA-20310.
When producer epoch exhaustion triggers producerId rotation, the coordinator may fail after writing the updated transaction metadata but before returning the
InitProducerIdresponse to the client. After failover, a retry from the client can be incorrectly rejected withPRODUCER_FENCED.The failure happens because the recovered transaction metadata does not restore the previous epoch information needed to recognize the retry correctly. In particular,
lastProducerEpochfalls back toNO_PRODUCER_EPOCHafter transaction log replay, soTransactionMetadata.prepareIncrementProducerEpoch(...)cannot identify the request as a valid retry of the earlier producerId rotation.This PR fixes that by persisting
lastProducerEpochinTransactionLogValuefor flexible transaction log records and restoring it during log replay.With this change, retries of
InitProducerIdafter failover are handled correctly when the original request triggered producerId rotation due to epoch exhaustion.Tests
lastProducerEpochInitProducerIdretry after failover during producerId rotation caused by epoch exhaustion.Other consideration
kafka/transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionMetadata.java
Lines 476 to 480 in 8ae35c0
This code is not affected by this changes
For
InitProducerId,TransactionCoordinatorvalidates the retry using values from the client request.In contrast, this block only validates a local state transition, so it is not directly affected by coordinator failover.