ijuma commented on a change in pull request #10620: URL: https://github.com/apache/kafka/pull/10620#discussion_r629703346
########## File path: clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java ########## @@ -710,8 +710,11 @@ private boolean appendsInProgress() { */ public void awaitFlushCompletion() throws InterruptedException { try { - for (ProducerBatch batch : this.incomplete.copyAll()) - batch.produceFuture.await(); + // Obtain a copy of all of the incomplete ProduceRequestResult(s) the time of the flush. + // We must be careful not to hold a reference to the ProduceBatch(s) so that garbage + // collection can occur on the contents. Review comment: I think I'd mention this bit from your message: `the sender will remove the producer batches from the original incomplete collection`. This explains why we should not hold to any batches. -- 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