clintropolis commented on a change in pull request #11643:
URL: https://github.com/apache/druid/pull/11643#discussion_r700107282



##########
File path: sql/src/main/java/org/apache/druid/sql/SqlLifecycleManager.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.sql;
+
+import com.google.common.collect.ImmutableList;
+import com.google.errorprone.annotations.concurrent.GuardedBy;
+import org.apache.druid.guice.LazySingleton;
+import org.apache.druid.sql.SqlLifecycle.State;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class manages only _authorized_ {@link SqlLifecycle}s. The main use 
case of this class is
+ * tracking running queries so that the cancel API can identify the lifecycles 
to cancel.
+ *
+ * This class is thread-safe as there are 2 or more threads that can access 
lifecycles at the same time
+ * for query running or query canceling.
+ */
+@LazySingleton
+public class SqlLifecycleManager

Review comment:
       it seems a shame to me that this has to exist and we can't instead 
improve `QueryScheduler` to allow `SqlLifecycle` to register cancellables (with 
cascading to native queryIds) and finishers to cleanup similar to what it does 
already for native queries, the reasoning being to consolidate cancellation 
logic in one place instead of it being spread around like it is right now. I'm 
not quite sure what exactly this looks like, but maybe less `Future` centric. 
The fork join pool parallel merge sequences could similarly be wired up to more 
proactively cancel merge tasks and also aren't future based, though I have 
prototyped at some point in the past just wrapping it in a Future to fit the 
interface.




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