TanYuxin-tyx commented on a change in pull request #17936: URL: https://github.com/apache/flink/pull/17936#discussion_r773664257
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/SortMergeResultPartitionReadSchedulerTest.java ########## @@ -192,6 +194,53 @@ public void testOnReadBufferRequestError() throws Exception { assertAllResourcesReleased(); } + @Test + public void testIncreaseDeadlineWhenRecycleBuffer() throws Exception { + testRequestDeadlineInternal(true); + assertTrue(readScheduler.getBufferRequestDeadline().hasTimeLeft()); + } + + @Test + public void testDeadlineTimeoutWhenNoRecycleBuffer() throws Exception { + testRequestDeadlineInternal(false); + assertFalse(readScheduler.getBufferRequestDeadline().hasTimeLeft()); + } + + private void testRequestDeadlineInternal(boolean needTriggerRecycleBuffer) throws Exception { + readScheduler.setRequestBufferDeadline(Deadline.fromNow(Duration.ofMillis(500))); + assertTrue(readScheduler.getBufferRequestDeadline().hasTimeLeft()); + + readScheduler.run(); + // Waiting for the deadline timeout + Thread.sleep(800); + + if (needTriggerRecycleBuffer) { + // If at least one buffer is recycled, the deadline will be increased + triggerRecycleBuffer(); + } + } + + private void triggerRecycleBuffer() throws Exception { Review comment: Thanks again for these comments. I have updated the code. Could you please help check it again? @wsry -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org