praveenc7 commented on code in PR #16793:
URL: https://github.com/apache/pinot/pull/16793#discussion_r2372856436


##########
pinot-core/src/main/java/org/apache/pinot/core/accounting/QueryAggregator.java:
##########
@@ -298,28 +213,63 @@ public int getAggregationSleepTimeMs() {
     return _sleepTime;
   }
 
+  /**
+   * Get the current QueryMonitorConfig
+   */
+  public QueryMonitorConfig getQueryMonitorConfig() {
+    return _queryMonitorConfig.get();
+  }
+
+  /**
+   * Log the current QueryMonitorConfig settings
+   */
+  private void logQueryMonitorConfig() {
+    QueryMonitorConfig config = getQueryMonitorConfig();
+    LOGGER.info("Updated Configuration for Query Monitor");
+    LOGGER.info("Xmx is {}", config.getMaxHeapSize());
+    LOGGER.info("_instanceType is {}", _instanceType);
+    LOGGER.info("_alarmingLevel of on heap memory is {}", 
config.getAlarmingLevel());
+    LOGGER.info("_criticalLevel of on heap memory is {}", 
config.getCriticalLevel());
+    LOGGER.info("_panicLevel of on heap memory is {}", config.getPanicLevel());
+    LOGGER.info("_normalSleepTime is {}", config.getNormalSleepTime());
+    LOGGER.info("_alarmingSleepTime is {}", config.getAlarmingSleepTime());
+    LOGGER.info("_oomKillQueryEnabled: {}", config.isOomKillQueryEnabled());
+    LOGGER.info("_minMemoryFootprintForKill: {}", 
config.getMinMemoryFootprintForKill());
+    LOGGER.info("_isCPUTimeBasedKillingEnabled: {}, 
_cpuTimeBasedKillingThresholdNS: {}",
+        config.isCpuTimeBasedKillingEnabled(), 
config.getCpuTimeBasedKillingThresholdNS());
+  }
+
+  /**
+   * Register MSE cancel callback for graceful query termination
+   */
+  public void registerMseCancelCallback(String queryId, MseCancelCallback 
callback) {
+    _queryCancelCallbacks.put(queryId, callback);
+  }
+
+  @Nullable
+  public MseCancelCallback getQueryCancelCallback(String queryId) {
+    return _queryCancelCallbacks.getIfPresent(queryId);
+  }
+
   // Implement getQueryResources
 
   public void 
preAggregate(List<CPUMemThreadLevelAccountingObjects.ThreadEntry> 
anchorThreadEntries) {
     LOGGER.debug("Running pre-aggregate for QueryAggregator.");
-    _sleepTime = _normalSleepTime;
-    _triggeringLevel = TriggeringLevel.Normal;
+    QueryMonitorConfig config = getQueryMonitorConfig();
+    _sleepTime = config.getNormalSleepTime();
+    _aggregatedUsagePerActiveQuery = null;
     collectTriggerMetrics();
     evalTriggers();
     if (_triggeringLevel == TriggeringLevel.HeapMemoryPanic) {
       killAllQueries(anchorThreadEntries);
-      LOGGER.error("Killed all queries and triggered gc!");
-      // Set the triggering level back to normal for aggregation phase.
-      _triggeringLevel = TriggeringLevel.Normal;

Review Comment:
   I think this is handled in the work in 
https://github.com/apache/pinot/pull/16728, where after killing the 
QueryThreadContext would be null for the query and hence it would skip 
aggregate/post-aggragate



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