Jiabao-Sun commented on code in PR #23564:
URL: https://github.com/apache/flink/pull/23564#discussion_r1369909942


##########
flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/rest/OperationRelatedITCase.java:
##########
@@ -119,18 +119,25 @@ List<String> submitOperation() throws Exception {
         SessionHandle sessionHandle = new 
SessionHandle(UUID.fromString(sessionHandleId));
         
assertThat(SQL_GATEWAY_SERVICE_EXTENSION.getSessionManager().getSession(sessionHandle))
                 .isNotNull();
+
+        OneShotLatch startLatch = new OneShotLatch();
+        Thread main = Thread.currentThread();
         OperationHandle operationHandle =
                 SQL_GATEWAY_SERVICE_EXTENSION
                         .getService()
                         .submitOperation(
                                 sessionHandle,
                                 () -> {
                                     try {
-                                        TimeUnit.SECONDS.sleep(10);
+                                        startLatch.trigger();
+                                        // keep operation in RUNNING state in 
response to cancel
+                                        // or close operations.
+                                        main.join();
                                     } catch (InterruptedException ignored) {
                                     }
                                     return NotReadyResult.INSTANCE;
                                 });
+        startLatch.await();

Review Comment:
   Thanks @WencongLiu.
   The Runnable work above is asynchronous, and the status will be turned to 
RUNNING only when runBefore method
   is executed. So we need a latch to prevent the state has not been turned 
from PENDING into RUNNING yet. 
   
   
https://github.com/apache/flink/blob/22c1eb44df7226c8e9045789e45c71c93668c644/flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/operation/OperationManager.java#L247-L269



-- 
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

Reply via email to