coltmcnealy-lh commented on code in PR #17527: URL: https://github.com/apache/kafka/pull/17527#discussion_r1837581786
########## clients/src/test/java/org/apache/kafka/clients/MockClient.java: ########## @@ -336,6 +336,12 @@ public List<ClientResponse> poll(long timeoutMs, long now) { copy.add(response); } + if (copy.isEmpty()) { + // Simulate time advancing. If no responses are received, then we know that + // we waited for the whole timeoutMs. + time.sleep(timeoutMs); Review Comment: @mjsax the problem is that the following test still passes on `trunk` using `new MockTime(1L)`. However, the test that I have in the PR as it stands passes on my branch but fails on trunk: ``` @Test public void senderThreadShouldNotGetStuckWhenThrottledAndAddingPartitionsToTxn() { // We want MockClient#poll() to advance time so that eventually the backoff expires. // client.advanceTimeDuringPoll(true); time = new MockTime(1L); ProducerIdAndEpoch producerIdAndEpoch = new ProducerIdAndEpoch(123456L, (short) 0); apiVersions.update("0", NodeApiVersions.create(ApiKeys.INIT_PRODUCER_ID.id, (short) 0, (short) 3)); TransactionManager txnManager = new TransactionManager(logContext, "testUnresolvedSeq", 60000, 100, apiVersions); setupWithTransactionState(txnManager); doInitTransactions(txnManager, producerIdAndEpoch); int throttleTimeMs = 1000; long startTime = time.milliseconds(); Node nodeToThrottle = metadata.fetch().nodeById(0); client.throttle(nodeToThrottle, throttleTimeMs); // Verify node is throttled a little bit. In real-life Apache Kafka, we observe that this can happen // as done above by throttling or with a disconnect / backoff. long currentPollDelay = client.pollDelayMs(nodeToThrottle, startTime); assertTrue(currentPollDelay > 0); assertTrue(currentPollDelay <= throttleTimeMs); txnManager.beginTransaction(); txnManager.maybeAddPartition(tp0); assertFalse(txnManager.hasInFlightRequest()); sender.runOnce(); assertTrue(txnManager.hasInFlightRequest()); long totalTimeToRunOnce = time.milliseconds() - startTime; // It should have blocked roughly only the backoffTimeMs and some change. assertTrue(totalTimeToRunOnce < REQUEST_TIMEOUT); } ``` -- 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