showuon commented on a change in pull request #11631:
URL: https://github.com/apache/kafka/pull/11631#discussion_r776731023
##########
File path:
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java
##########
@@ -517,15 +517,13 @@ public boolean poll(Timer timer, boolean
waitForJoinGroup) {
}
}
} else {
- // For manually assigned partitions, if there are no ready nodes,
await metadata.
+ // For manually assigned partitions, if coordinator is unknown,
make sure we lookup one and await metadata.
// If connections to all nodes fail, wakeups triggered while
attempting to send fetch
// requests result in polls returning immediately, causing a tight
loop of polls. Without
// the wakeup, poll() with no channels would block for the
timeout, delaying re-connection.
- // awaitMetadataUpdate() initiates new connections with configured
backoff and avoids the busy loop.
- // When group management is used, metadata wait is already
performed for this scenario as
- // coordinator is unknown, hence this check is not required.
- if (metadata.updateRequested() &&
!client.hasReadyNodes(timer.currentTimeMs())) {
- client.awaitMetadataUpdate(timer);
+ // awaitMetadataUpdate() in ensureCoordinatorReady initiates new
connections with configured backoff and avoids the busy loop.
+ if (coordinatorUnknown() && !ensureCoordinatorReady(timer)) {
+ return false;
Review comment:
Before the change, we will wait for the metadata update if no nodes
available, to avoid busy loop when in non consumer group mode. After the
change, we did as the group management did, to call `ensureCoordinatorReady`
when coordinator unknown. And in `ensureCoordinatorReady`. This way, we can
also make sure to handle the `FindCoordinatorFuture` well (and clear it) inside
`ensureCoordinatorReady`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]