Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.apache.flink.test.util.TestUtils;
import org.apache.flink.testutils.executor.TestExecutorExtension;
import org.apache.flink.util.CollectionUtil;
import org.apache.flink.util.ExceptionUtils;
import org.apache.flink.util.UserClassLoaderJarTestUtils;
import org.apache.flink.util.concurrent.ExecutorThreadFactory;
import org.apache.flink.util.function.RunnableWithException;
Expand Down Expand Up @@ -957,14 +958,29 @@ void testReleaseLockWhenFailedToSubmitOperation() throws Exception {
latch.countDown();
// Wait the first operation finishes
awaitOperationTermination(service, sessions.get(0), operations.get(0));
// Service is able to submit operation
// Service is able to submit operation. The first operation turns terminal before its
// thread is back in the pool, so retry until a thread is free.
CountDownLatch success = new CountDownLatch(1);
service.submitOperation(
sessionHandle,
CommonTestUtils.waitUtil(
() -> {
success.countDown();
return getDefaultResultSet();
});
try {
service.submitOperation(
sessionHandle,
() -> {
success.countDown();
return getDefaultResultSet();
});
return true;
} catch (SqlGatewayException e) {
if (ExceptionUtils.findThrowable(e, RejectedExecutionException.class)
.isPresent()) {
return false;
}
throw e;
}
},
Duration.ofSeconds(10),
"The pool never freed a thread to accept the operation.");
CommonTestUtils.waitUtil(
() -> success.getCount() == 0, Duration.ofSeconds(10), "Should come to end.");
}
Expand Down