chesnokoff commented on code in PR #13793:
URL: https://github.com/apache/ignite/pull/13793#discussion_r4492562715


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java:
##########
@@ -737,8 +737,11 @@ public void testSensitiveInformationHiding() throws 
Exception {
                 }
             });
 
-            assertEquals(13, qryCnt.get()); // CREATE AS SELECT counts as two 
queries.
-            assertEquals(8, planCnt.get()); // DDL queries don't produce 
plans, except CREATE AS SELECT.
+            // CREATE AS SELECT counts as two queries.
+            assertTrue("qryCnt = " + qryCnt.get(), waitForCondition(() -> 
qryCnt.get() == 13, 5_000));
+
+            // DDL queries don't produce plans, except CREATE AS SELECT.
+            assertTrue("planCnt = " + planCnt.get(), waitForCondition(() -> 
planCnt.get() == 8, 5_000));

Review Comment:
   For now I'm not sure that the fix is correct. Let's consider `qryCnt`.
   - It's modified only in body of `stopCollectStatisticsAndRead`
   - `stopCollectStatisticsAndRead` does not start any new thread. So the body 
of `stopCollectStatisticsAndRead` and next asserts are executed in the same 
thread
   - So line `qryCnt.incrementAndGet()` happens before `assertEquals(13, 
qryCnt.get())` and I do not see any race conditions between these two lines
   
   It's more like `stopCollectStatisticsAndRead` is called before all sql calls 
are recorded to perfstat. So we have to wait execution and recording all sql 
calls before calling `stopCollectStatisticsAndRead`
   
   The same for `planCnt`.
   
   I suggest you double-check and investigate smth like
   ```
   RunningQueryManager qryMgr =
       grid(0).context().query().runningQueryManager();
   
   Consumer<GridQueryFinishedInfo> lsnr = q -> finishedCnt.incrementAndGet();
   
   qryMgr.registerQueryFinishedListener(lsnr);
   ```
   
   and to wait all SQLs executions
   ```
   assertTrue(waitForCondition(() -> finishedCnt.get() == 13, 5_000));
   ```
   
   Finally, there is still one failed run: 
https://ci2.ignite.apache.org/buildConfiguration/IgniteTests24Java8_CalciteSql3/9473363



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to