-
Notifications
You must be signed in to change notification settings - Fork 14.5k
KAFKA-17853: Fix termination issue in ConsoleConsumer and ConsoleShareConsumer #19886
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
base: trunk
Are you sure you want to change the base?
Conversation
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. I like the approach but want to review more deeply. A few comments to address.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/NetworkClientDelegate.java
Outdated
Show resolved
Hide resolved
clients/src/main/java/org/apache/kafka/clients/consumer/internals/NetworkClientDelegate.java
Show resolved
Hide resolved
clients/src/main/java/org/apache/kafka/clients/consumer/internals/NetworkClientDelegate.java
Outdated
Show resolved
Hide resolved
Great to see the fix in the area, thanks for looking into this. |
Another edge case here: |
Hey, thanks for looking into this! Sorry I haven't had the time to look in detail, but just couple of high level comments:
This means "close with default close timeout of 30s". So in a way, it's not unexpected that it waits right?. We should ensure that's what we want from the console consumers. Ex. calling |
Hi @lianetm, thanks for the review.
|
Thanks for the PR, @ShivsundarR. Since this change affects all consumer use cases, we need to tread carefully 😄 The console consumer is closing the underlying consumer with the default That said, the Is there an approach by which we can "prove" that continuing to make requests is pointless? |
Hi @kirktrue, thanks for the review.
This was my line of thought, does this sound good? |
https://issues.apache.org/jira/browse/KAFKA-17853 -
There is an issue with the console share consumer where if the broker
is unavailable, even after force terminating using ctrl-c, the consumer
does not shut down immediately. It takes around ~30 seconds to close
once the broker shuts down.
The console consumer on the other hand, was supposedly shutting down
immediately once we press ctrl-c. On reproducing the issue with a local
kafka server, I observed the issue was present in both the console
consumer and the console share consumer.
Issue :
On seeing the client debug logs, this issue seemed related to network
thread sending repeated
FindCoordinator
requests until the timerexpired. This was happening in both the console-consumer and
console-share-consumer.
Debug logs showed that when the broker is shut down, the heartbeat
fails with a
DisconnectException
(which is retriable), this triggers afindCoordinator
request on the network thread which retries until thedefault timeout expires.
This request is sent even before we trigger a close on the consumer,
so once we press ctrl-c, although the
ConsumerNetworkThread::close()
is triggered, it waits for the default timeout until all the requests
are sent out for a graceful shutdown.
PR aims to fix this issue by adding a check in
NetworkClientDelegate
to remove any pending unsent requests(with empty node values) during
close. This would avoid unnecessary retries and the consumers would
shut down immediately upon termination.
Share consumers shutting down after the fix.
Regular consumers shutting down after the fix.