Alwaysgaurav1 opened a new pull request, #23890: URL: https://github.com/apache/kafka/pull/23890
### Jira * [KAFKA-21286](https://issues.apache.org/jira/browse/KAFKA-21286): Share consumer may delay fatal startup errors while waiting for the first heartbeat ### Problem Following KAFKA-19804, the initial heartbeat interval defaults to `request.timeout.ms` (30s) while joining the group to avoid busy-spinning. In `ShareConsumerImpl.pollForFetches()`, the wait duration on `fetchBuffer.awaitNotEmpty(pollTimer)` was calculated solely as `Math.min(applicationEventHandler.maximumTimeToWait(), timer.remainingMs())`. When a member is joining and has not yet received assignments (`subscriptions.numAssignedPartitions() == 0`), `maximumTimeToWait()` returns the 30-second request timeout. If a fatal error (such as `GROUP_AUTHORIZATION_FAILED`) arrives from the coordinator, the background event handler enqueues an `ErrorEvent`, but the application thread was blocked in `fetchBuffer.awaitNotEmpty` for the full 30 seconds before exiting `pollForFetches()` to process background errors. ### Solution Align `ShareConsumerImpl` with `AsyncKafkaConsumer` by capping the fetch buffer wait timeout at `retryBackoffMs` when no partitions are assigned (`subscriptions.numAssignedPartitions() == 0`). 1. Added `numAssignedPartitions()` to `AbstractSubscriptionState` and implemented it in `ShareSubscriptionState`. 2. Loaded `retryBackoffMs` from configuration into `ShareConsumerImpl`. 3. In `ShareConsumerImpl.pollForFetches()`, capped `pollTimeout` at `retryBackoffMs` when `subscriptions.numAssignedPartitions() == 0`. 4. Added unit tests in `ShareSubscriptionStateTest` and `ShareConsumerImplTest` to verify that fetch buffer waits and fatal error reporting during startup are bounded by `retryBackoffMs`. -- 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]
