artemlivshits commented on code in PR #12570: URL: https://github.com/apache/kafka/pull/12570#discussion_r970145425
########## clients/src/test/java/org/apache/kafka/clients/producer/internals/RecordAccumulatorTest.java: ########## @@ -1137,23 +1137,26 @@ public void onCompletion(RecordMetadata metadata, Exception exception) { assertEquals(partition1, partition.get()); assertEquals(2, mockRandom.get()); - // Produce large record, we should switch to next partition. + // Produce large record, we switched to next partition by previous produce, but + // for this produce the switch would be disabled because of incomplete batch. accum.append(topic, RecordMetadata.UNKNOWN_PARTITION, 0L, null, largeValue, Record.EMPTY_HEADERS, callbacks, maxBlockTimeMs, false, time.milliseconds(), cluster); assertEquals(partition2, partition.get()); - assertEquals(3, mockRandom.get()); + assertEquals(2, mockRandom.get()); Review Comment: Switching the partition only when the batch is complete make it effectively switch before we create a new batch. In the test the step 2 seems to be an outlier, because the large record + small record seems to exceed the batch.size * 2, so the even though the switch is disabled at the end of step 2, it still happens. I've increase the batch.size in the test, now all tests switch partition before creating a batch. -- 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