-
Notifications
You must be signed in to change notification settings - Fork 14.9k
KAFKA-19128: Kafka Streams should not get offsets when close dirty #19450
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
Conversation
bbejeck
left a comment
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.
Thanks for the PR @aliehsaeedii - this seems and like a good change overall looks good - I just have one minor comment. I'll defer final say to @mjsax since he recently made changes in this area.
| // we call this function only to flush the case if necessary | ||
| // before suspending and closing the topology | ||
| task.prepareCommit(); | ||
| task.flush(); |
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.
The SteamTask.prepareCommit() set a boolean flag hasPending TxCommit if using EOS and the commitNeeded flag is true - is it OK to bypass that? I'm thinking so but I'd like to confirm.
|
Thanks for the PR -- I am wondering if it would be better to actually change As we don't want to commit, we should not even return an empty Btw: there is multiple places in with we "close dirty", to changing from We also don't want to lose the guard to check the task state, which we do inside |
mjsax
left a comment
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.
Did I miss it, or is there no new test for this case? Would be good to at least add one more test to StreamsTaskTest; something like shouldNotGetOffsetsIfPerpareCommitDirty() verifying that we return null, and ideally also that committableOffsetsAndMetadata() was not called (the second check is more tricky -- need some creativity I guess).
| @Override | ||
| public Map<TopicPartition, OffsetAndMetadata> prepareCommit() { | ||
| public Map<TopicPartition, OffsetAndMetadata> prepareCommit(final boolean clean) { | ||
| if (!clean) { |
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.
Should this to to the end of the method? So we preserve all logging?
Or maybe even don't check clean flag at all, because StandbyTasks should also never return offsets, and we could just change return Collections.emptyMap(); to return null; directly?
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 check the clean flag for accurate logs.
Let's keep the Collections.emptyMap() when close clean to keep the logic as it is?!
streams/src/main/java/org/apache/kafka/streams/processor/internals/StandbyTask.java
Outdated
Show resolved
Hide resolved
streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java
Outdated
Show resolved
Hide resolved
I think the 2nd check is not necessary since if |
bbejeck
left a comment
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.
LGTM
|
Thanks for the fix! Merged to |
Kafka Streams calls
prepareCommit()inTaskmanager#closeTaskDirty().However, the dirty task must not get committed and therefore,
prepare-commit tasks such as getting offsets should not be needed as
well. The only thing needed before closing a task dirty is flushing.
Therefore, separating
flushandprepareCommitcould be a good fix.Reviewers: Bill Bejeck [email protected], Matthias J. Sax
[email protected]