Github user ppadma commented on a diff in the pull request:
https://github.com/apache/drill/pull/1051#discussion_r153278034
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java ---
@@ -221,11 +200,15 @@ public QueryManager getQueryManager() {
}
/**
- * Cancel the query. Asynchronous -- it may take some time for all
remote fragments to be
- * terminated.
+ * Cancel the query. Asynchronous -- it may take some time for all
remote fragments to be terminated.
+ * For planning and enqueued states we cancel immediately since these
states are done locally.
+ *
+ * Note this can be called from outside of run() on another thread, or
after run() completes
*/
public void cancel() {
- // Note this can be called from outside of run() on another thread, or
after run() completes
+ if (QueryState.PLANNING == state || QueryState.ENQUEUED == state) {
+ moveToState(QueryState.CANCELLATION_REQUESTED, null);
--- End diff --
Please add a comment explaining why you are moving to
CANCELLATION_REQUESTED state only when query is in PLANNING and ENQUEUED
states. For ex., why not PREPARING State ?
---