-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][Txn] Support for commit idempotency. #20356
Open
thetumbled
wants to merge
14
commits into
apache:master
Choose a base branch
from
thetumbled:Feature_CommitIdempotency
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
github-actions
bot
added
the
doc-required
Your PR changes impact docs and you will update later.
label
May 19, 2023
Please keep this PR separate so that it can help committers review it. |
fixed, this is the solely PR related to PIP-255. |
The pr had no activity for 30 days, mark with Stale label. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
PIP:
#19744
Motivation
Message queues such as Kafka and Pulsar can only guarantee the exactly-once semantics provided by the transaction feature under the specific use scenario of
consume-transform-produce
pattern, that is, a transaction contains both production and consumption.The operations in the transaction include the production on the sink side and the offset submission on the source side.
Using the atomicity of the transaction, these two operations are either completed at the same time or not completed at the same time. It does not need to worry about whether the transaction is committed successfully, because regardless of whether it is successful or not, the end-to-end state is consistent before and after. Therefore, transaction feature implemented by Kafka and Pulsar only support commit or abort once, and it is illegal to repeatedly submit commit or abort requests afterwards, that is, they do not support the idempotence of commit operations.
But in many other use cases, which is different from
consume-transform-produce
pattern, we need to know the accurate state of the transaction after the commit operation is submitted. For example,In the case of
produce-only
, the transaction only contains the production operation, and the offset submission operation is not included, which is simillar to RocketMQ.The exactly-once semantics guaranteed by Flink is based on the
Two-Phase Commit
protocol implemented by Flink itself. When connecting to an external system, Flink has requirements for external system to ensure the exact once semantics:The details can be found in the following link:
https://www.ververica.com/blog/end-to-end-exactly-once-processing-apache-flink-apache-kafka
Though Kafka do not support for idempotence of commit operations, but Flink-Kafka-Connector do some tricks to achieve the idempotence of commit operations for the last transaction, so that Flink+Kafka can guarantee the exactly-once semantics in most of the cases, but still with some risks.
But for Pulsar, it is impossible to achieve any idempotence of commit operations currently, because the implementation of transaction in pulsar is quite different from kafka. I have post a blog to analyze the difference between Pulsar and Kafka. https://blog.csdn.net/m0_43406494/article/details/130344399
Modifications
TransactionMetadataPreserver
to store the terminated transaction metadata which is a component of TC.TrsansactionNotFound
exception, we will query theTransactionMetadataPreserver
to know the state of the transaction.clientName
to the transaction, andTransactionMetadataPreserver
will preserveTransactionMetaPersistCount
number of transaction metadata for each client.API Changes
Verifying this change
(Please pick either of the following options)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: thetumbled#21