kfaraz commented on code in PR #17470:
URL: https://github.com/apache/druid/pull/17470#discussion_r1976533905


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/SegmentLoadStatusFetcher.java:
##########
@@ -423,11 +424,15 @@ public enum State
      * The time spent waiting for segments to load exceeded 
org.apache.druid.msq.exec.SegmentLoadWaiter#TIMEOUT_DURATION_MILLIS.
      * The SegmentLoadWaiter exited without failing the task.
      */
-    TIMED_OUT;
+    TIMED_OUT,
+    /**
+     * All segments which need to be loaded have been loaded, and the 
SegmentLoadWaiter exited successfully.
+     */
+    DONE;

Review Comment:
   how is this different from SUCCESS?



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/SegmentLoadStatusFetcher.java:
##########
@@ -149,46 +148,46 @@ public void waitForSegmentsToLoad()
     try {
       FutureUtils.getUnchecked(executorService.submit(() -> {
         long lastLogMillis = -TimeUnit.MINUTES.toMillis(1);
-        try {
-          while (!(hasAnySegmentBeenLoaded.get() && 
versionLoadStatusReference.get().isLoadingComplete())) {
-            // Check the timeout and exit if exceeded.
-            long runningMillis = new Interval(startTime, 
DateTimes.nowUtc()).toDurationMillis();
-            if (runningMillis > TIMEOUT_DURATION_MILLIS) {
-              log.warn(
-                  "Runtime[%d] exceeded timeout[%d] while waiting for segments 
to load. Exiting.",
-                  runningMillis,
-                  TIMEOUT_DURATION_MILLIS
-              );
-              updateStatus(State.TIMED_OUT, startTime);
-              return;
-            }
+        while (true) {
+          if (DateTimes.nowUtc().getMillis() - startTime.getMillis() > 
TIMEOUT_DURATION_MILLIS) {
+            log.warn("Timed out waiting for segments to load");
+            break;
+          }
 
-            if (runningMillis - lastLogMillis >= TimeUnit.MINUTES.toMillis(1)) 
{
-              lastLogMillis = runningMillis;
-              log.info(
-                  "Fetching segment load status for datasource[%s] from 
broker",
-                  datasource
-              );
+          try {
+            SqlQuery sqlQuery = new SqlQuery(
+                StringUtils.format(LOAD_QUERY, datasource, 
versionsConditionString),
+                ResultFormat.ARRAY,
+                false,
+                false,
+                false,
+                null,
+                null
+            );
+            
+            SqlTaskStatus taskStatus = 
FutureUtils.getUnchecked(brokerClient.submitSqlTask(sqlQuery), true);
+            if (taskStatus.getState() == TaskState.SUCCESS) {

Review Comment:
   It is very unlikely that this `taskStatus` will ever be success or even 
failed. The task would have just been submitted to the Overlord.
   
   Moreover, this use case doesn't require submitting an MSQ task to the 
Overlord since the LOAD_QUERY is just a sys query.



##########
extensions-core/multi-stage-query/pom.xml:
##########
@@ -60,6 +60,13 @@
             <version>${project.parent.version}</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.druid</groupId>
+            <artifactId>druid-sql</artifactId>
+            <version>${project.parent.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>

Review Comment:
   It is not just used in tests anymore, so `scope` should be `provided` 
instead.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to