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


##########
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 at all since the LOAD_QUERY is just a sys query.



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