-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-27762][connector/kafka] Catch WakeupException and retry KafkaConsumer invocations in split assignment #19828
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
|
Sorry to bother you. I'm trying to simplify the question i had: You have improved the logic of I'll make an example by referring source code of Is it correct? |
…onsumer invocations in split assignment
|
Thanks for the review @zou-can ! Initially I was trying to fix this case from the root that |
|
@becketqin @leonardBang Please take a look when you are available. Thanks! |
| try { | ||
| return consumerCall.get(); | ||
| } catch (WakeupException we) { | ||
| // Do nothing here and the loop will retry the consumer call. |
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.
please add log here which is helpful if we can not leave the loop
| * <p>Under this case we need to catch the {@link WakeupException} and retry the operation. | ||
| */ | ||
| private <V> V retryOnWakeup(Supplier<V> consumerCall, String description) { | ||
| while (true) { |
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 think we‘d better remove the loop condition as all calls on consumer is thread-safe that means we can meet the WakeupException at most once, we can retry in catch code block
| try { | ||
| return consumerCall.get(); | ||
| } catch (WakeupException we) { | ||
| LOG.debug( |
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.
debug level log is meaningless for troubleshooting, because we still need to change the online logger config when exception happens, could we improve it to INFO level?
leonardBang
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 @PatrickRen for the update, LGTM.
|
@PatrickRen It looks good. Thanks for your efforts! |
|
@PatrickRen Could you also open the PR for release-1.15 and release-1.14? |
…onsumer invocations in split assignment This closes apache#19828.
…onsumer invocations in split assignment This closes apache#19828.
…onsumer invocations in split assignment This closes apache#19828.
…onsumer invocations in split assignment This closes apache#19828.
…onsumer invocations in split assignment This closes apache#19828.
…onsumer invocations in split assignment This closes apache#19828.
What is the purpose of the change
This pull request improves the logic of
KafkaPartitionSplitReaderthatwakeup()should only wake up the blockingKafkaConsumer#polloperation, otherwise the wake-up might be delayed to the nextConsumerNetworkClient#pollcall when handling new splits, which will throw aWakeupException.Brief change log
isPollingto make sure the wakeup method only unblocks KafkaConsumer#pollKafkaPartitionSplitReaderVerifying this change
This change is covered by the new
KafkaPartitionSplitReaderTest#testWakeupThenAssigncase.Does this pull request potentially affect one of the following parts:
@Public(Evolving): (yes / no)Documentation