snleee commented on code in PR #8911:
URL: https://github.com/apache/pinot/pull/8911#discussion_r899658714


##########
pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java:
##########
@@ -261,12 +272,22 @@ private DataTable processQueryInternal(ServerQueryRequest 
queryRequest, Executor
       _serverMetrics.addMeteredTableValue(tableNameWithType, 
ServerMeter.NUM_MISSING_SEGMENTS, numMissingSegments);
     }
 
+    long minConsumingFreshnessTimeMs = Long.MAX_VALUE;
     if (numConsumingSegments > 0) {
-      long minConsumingFreshnessTimeMs = minIngestionTimeMs != Long.MAX_VALUE 
? minIngestionTimeMs : minIndexTimeMs;
-      LOGGER.debug("Request {} queried {} consuming segments with 
minConsumingFreshnessTimeMs: {}", requestId,
-          numConsumingSegments, minConsumingFreshnessTimeMs);
+      minConsumingFreshnessTimeMs = minIngestionTimeMs != Long.MAX_VALUE ? 
minIngestionTimeMs : minIndexTimeMs;
       metadata.put(MetadataKey.NUM_CONSUMING_SEGMENTS_PROCESSED.getName(), 
Integer.toString(numConsumingSegments));
       metadata.put(MetadataKey.MIN_CONSUMING_FRESHNESS_TIME_MS.getName(), 
Long.toString(minConsumingFreshnessTimeMs));
+      LOGGER.debug("Request {} queried {} consuming segments with 
minConsumingFreshnessTimeMs: {}", requestId,
+          numConsumingSegments, minConsumingFreshnessTimeMs);
+    } else if (numConsumingSegments == 0 && maxEndTimeMs != Long.MIN_VALUE) {
+      minConsumingFreshnessTimeMs = maxEndTimeMs;
+      metadata.put(MetadataKey.MIN_CONSUMING_FRESHNESS_TIME_MS.getName(), 
Long.toString(maxEndTimeMs));
+      LOGGER.debug("Request {} queried {} consuming segments with 
minConsumingFreshnessTimeMs: {}", requestId,
+          numConsumingSegments, minConsumingFreshnessTimeMs);
+    } else if (numOnlineSegments == 0) {
+      // case: no immutable segments, no metric emitted
+      LOGGER.warn("Request {} queried no consuming or online segments, with 
minConsumingFreshnessTimeMs: {}", requestId,

Review Comment:
   My reasoning was that we already faced not-happy-path when 
`numConsumingSegments ==0 0` so having a lot of lines of the same log every 
time the query runs when this condition is met probably would not help too 
much. (Current code only logs `debug` when numConsumingSegments ==0 but that's 
already not-happy situation.
   
   Instead, we should find the issue by the alert when `numConsumingSegments == 
0` and this is being addressed by the metric that will be added by 
@sajjad-moradi . How do you think?



##########
pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java:
##########
@@ -261,12 +272,22 @@ private DataTable processQueryInternal(ServerQueryRequest 
queryRequest, Executor
       _serverMetrics.addMeteredTableValue(tableNameWithType, 
ServerMeter.NUM_MISSING_SEGMENTS, numMissingSegments);
     }
 
+    long minConsumingFreshnessTimeMs = Long.MAX_VALUE;
     if (numConsumingSegments > 0) {
-      long minConsumingFreshnessTimeMs = minIngestionTimeMs != Long.MAX_VALUE 
? minIngestionTimeMs : minIndexTimeMs;
-      LOGGER.debug("Request {} queried {} consuming segments with 
minConsumingFreshnessTimeMs: {}", requestId,
-          numConsumingSegments, minConsumingFreshnessTimeMs);
+      minConsumingFreshnessTimeMs = minIngestionTimeMs != Long.MAX_VALUE ? 
minIngestionTimeMs : minIndexTimeMs;
       metadata.put(MetadataKey.NUM_CONSUMING_SEGMENTS_PROCESSED.getName(), 
Integer.toString(numConsumingSegments));
       metadata.put(MetadataKey.MIN_CONSUMING_FRESHNESS_TIME_MS.getName(), 
Long.toString(minConsumingFreshnessTimeMs));
+      LOGGER.debug("Request {} queried {} consuming segments with 
minConsumingFreshnessTimeMs: {}", requestId,
+          numConsumingSegments, minConsumingFreshnessTimeMs);
+    } else if (numConsumingSegments == 0 && maxEndTimeMs != Long.MIN_VALUE) {
+      minConsumingFreshnessTimeMs = maxEndTimeMs;
+      metadata.put(MetadataKey.MIN_CONSUMING_FRESHNESS_TIME_MS.getName(), 
Long.toString(maxEndTimeMs));
+      LOGGER.debug("Request {} queried {} consuming segments with 
minConsumingFreshnessTimeMs: {}", requestId,
+          numConsumingSegments, minConsumingFreshnessTimeMs);
+    } else if (numOnlineSegments == 0) {
+      // case: no immutable segments, no metric emitted
+      LOGGER.warn("Request {} queried no consuming or online segments, with 
minConsumingFreshnessTimeMs: {}", requestId,

Review Comment:
   My reasoning was that we already faced not-happy-path when 
`numConsumingSegments == 0` so having a lot of lines of the same log every time 
the query runs when this condition is met probably would not help too much. 
(Current code only logs `debug` when numConsumingSegments ==0 but that's 
already not-happy situation.
   
   Instead, we should find the issue by the alert when `numConsumingSegments == 
0` and this is being addressed by the metric that will be added by 
@sajjad-moradi . How do you think?



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