-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Flink: Enable multiple flink sinks for the same table in the same job #6528
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a problem. it gets the
jobVertexId(a UUID like string). I verified it by setting theuidPrefix=iceberg-sinkinTestFlinkIcebergSink.Then I can see the
operatorUniqueIdvalue as jobVertexId of0e4eaa3db14ae3b6752b25172fd05c50. It can change when the job graph changed (e.g. adding a stateless map operator). Then we won't be able to match the operator id properly.Ideally, we want to use the operator uid from Flink, which can be set by users. See the code from
FlinkSink.if uid is not provided by application, Flink automatically generates a UUID by default. Setting uid for stateful operator (like Iceberg committer) is a best practice. Flink uses uid to match state description. if uid changed, old state won't be matched and restored. uid works perfectly for this purpose. But I am not sure what is the best way to retrieve the
uidin theinitializeStatemethod.I can see the operator name from debugger, which is also set by

FlinkSinkbased onuidPrefix. It will be unique asuidPrefixshould be unique. Nonetheless, it is still not the ideal candidate/replacement foruidthough.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did more experiment. if the
uidPrefixis set inFlinkSink, then it seems thatgetOperatorUniqueIDdoes return a stable ID even if the job DAG changed.if
uidPrefixis not set inFlinkSink, DAG change leads to unstable/different values fromgetOperatorUniqueID. This is not really a problem, because it is the same situation if we use operatoruid. we should always setuidPrefixforFlinkSinkas best practice for stateful committer operator.In summary, using
getOperatorUniqueIDseems acceptable to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @hililiwei @openinx and see if they have other suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operatorUniqueIdis deterministaclly generated based on the uid of the operator which is used already by Flink to assign the state to this operator. This is competely correct.