soarez commented on code in PR #14836: URL: https://github.com/apache/kafka/pull/14836#discussion_r1408475724
########## core/src/test/scala/unit/kafka/server/BrokerLifecycleManagerTest.scala: ########## @@ -201,7 +201,7 @@ class BrokerLifecycleManagerTest { while (!future.isDone || context.mockClient.hasInFlightRequests) { context.poll() manager.eventQueue.wakeup() - context.time.sleep(100) + context.time.sleep(5) Review Comment: > there will be 29 extra HeartBeatRequests continuously every heartbeat interval, right? No, I think it's just once. After receiving a response to a `HeartBeatRequest`, a `BrokerHeartbeatResponseEvent` runs which ends up calling `scheduleNextCommunication`. This queues a CommunicationEvent (which sends the next heartbeat) to the KafkaEventQueue using a tag. Because the tag is always the same, any previously queued event with the same tag is cancelled. So even if we receive 2 `HeartBeatRequest` responses in quick succession, we only send a single following heartbeat request. Taking another look at the code, I'm wrong about the extra requests, `propagateDirectoryFailure` triggers the "extra heartbeat" also using `scheduleNextCommunication` — so the pending `HeartBeatRequest` is cancelled indeed! ########## core/src/test/scala/unit/kafka/server/BrokerLifecycleManagerTest.scala: ########## @@ -201,7 +201,7 @@ class BrokerLifecycleManagerTest { while (!future.isDone || context.mockClient.hasInFlightRequests) { context.poll() manager.eventQueue.wakeup() - context.time.sleep(100) + context.time.sleep(5) Review Comment: > there will be 29 extra HeartBeatRequests continuously every heartbeat interval, right? No, I think it's just once. After receiving a response to a `HeartBeatRequest`, a `BrokerHeartbeatResponseEvent` runs which ends up calling `scheduleNextCommunication`. This queues a CommunicationEvent (which sends the next heartbeat) to the KafkaEventQueue using a tag. Because the tag is always the same, any previously queued event with the same tag is cancelled. So even if we receive 2 `HeartBeatRequest` responses in quick succession, we only send a single following heartbeat request. Taking another look at the code, I'm wrong about the extra requests, `propagateDirectoryFailure` triggers the "extra heartbeat" also using `scheduleNextCommunication` — so the pending `HeartBeatRequest` is cancelled indeed! -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org