klsince commented on code in PR #9171: URL: https://github.com/apache/pinot/pull/9171#discussion_r944951198
########## pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java: ########## @@ -167,6 +182,60 @@ private String getDefaultBrokerId() { } } + @Override + public Map<Long, String> getRunningQueries() { + return _queriesById.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()._query)); + } + + @VisibleForTesting + Set<ServerInstance> getRunningServers(long queryId) { + if (_queriesById.isEmpty()) { + return Collections.emptySet(); + } + return _queriesById.get(queryId)._servers; + } + + @Override + public boolean cancelQuery(long queryId, int timeoutMs, Executor executor, HttpConnectionManager connMgr, + Map<String, Integer> serverResponses) { + QueryRoutingTable routingTable = _queriesById.get(queryId); + if (routingTable == null) { + return false; + } + String globalId = getGlobalQueryId(queryId); + List<String> serverUrls = new ArrayList<>(); + for (ServerInstance server : routingTable._servers) { + serverUrls.add(String.format("%s/query/%s", server.getAdminEndpoint(), globalId)); + } + if (serverUrls.isEmpty()) { + LOGGER.debug("No servers running the query: {} right now", globalId); + return true; Review Comment: as explained in a comment below, if cancel request comes earlier even before query gets scheduled, then I'd suggest just to let the query continue and users can simply check running queries and make another cancel request. Cancel request is idempotent. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org