mumrah commented on a change in pull request #9749: URL: https://github.com/apache/kafka/pull/9749#discussion_r554113195
########## File path: core/src/main/scala/kafka/server/AlterIsrManager.scala ########## @@ -122,43 +121,47 @@ class DefaultAlterIsrManager( override def start(): Unit = { controllerChannelManager.start() - scheduler.schedule("send-alter-isr", propagateIsrChanges, 50, 50, TimeUnit.MILLISECONDS) } override def shutdown(): Unit = { controllerChannelManager.shutdown() } override def submit(alterIsrItem: AlterIsrItem): Boolean = { - unsentIsrUpdates.putIfAbsent(alterIsrItem.topicPartition, alterIsrItem) == null + if (unsentIsrUpdates.putIfAbsent(alterIsrItem.topicPartition, alterIsrItem) == null) { + if (inflightRequest.compareAndSet(false, true)) { + // optimistically set the inflight flag even though we haven't sent the request yet + scheduler.schedule("send-alter-isr", propagateIsrChanges, 1, -1, TimeUnit.MILLISECONDS) Review comment: Yea I don't see any problem with that ########## File path: core/src/main/scala/kafka/server/AlterIsrManager.scala ########## @@ -122,43 +121,47 @@ class DefaultAlterIsrManager( override def start(): Unit = { controllerChannelManager.start() - scheduler.schedule("send-alter-isr", propagateIsrChanges, 50, 50, TimeUnit.MILLISECONDS) } override def shutdown(): Unit = { controllerChannelManager.shutdown() } override def submit(alterIsrItem: AlterIsrItem): Boolean = { - unsentIsrUpdates.putIfAbsent(alterIsrItem.topicPartition, alterIsrItem) == null + if (unsentIsrUpdates.putIfAbsent(alterIsrItem.topicPartition, alterIsrItem) == null) { + if (inflightRequest.compareAndSet(false, true)) { Review comment: You're right, there's a race between the isEmpty check and clearing the inflight flag. Good catch ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org