Michael Smith has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/21803 )

Change subject: IMPALA-915: Support cancel queries in frontend
......................................................................


Patch Set 42:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/21803/41/fe/src/main/java/org/apache/impala/service/Canceller.java
File fe/src/main/java/org/apache/impala/service/Canceller.java:

http://gerrit.cloudera.org:8080/#/c/21803/41/fe/src/main/java/org/apache/impala/service/Canceller.java@94
PS41, Line 94:   public static void cancel(TUniqueId queryId) {
> What happens if a query is cancelled twice with the second cancel coming in
I think:
1. cancelledThreads_.add may be called twice; it either ignores the 2nd add 
because it's already present, or adds it back
2. queryThread.interrupt() is called twice; this should be fine, interrupt 
either halts a system call or sets the interrupt flag on the thread, so the 2nd 
call will do nothing

If the 2nd cancel reaches queryThreads_.containsKey before unregister, it will 
do nothing else. Unregister will then remove the key from cancelledThreads_.

If the 2nd cancel reaches queryThreads_.containsKey during unregister, we'll 
get two calls to cancelledThreads_.remove, which is fine, 2nd one is a noop.

If the 2nd cancel reaches queryThreads_.containsKey after unregister, it will 
call cancelledThreads_.remove, which either cleans up its earlier add or is a 
noop.

So:
1. cancelledThreads_.add is basically idempotent; either unregister or cancel 
will clean it up later.
2. queryThread.interrupt is idempotent, we can call it multiple times without 
an issue.
3. cancelledThreads_.remove is idempotent; it either removes the queryThread or 
is a noop.

I can add a test where multiple cancels are sent at the same time.



--
To view, visit http://gerrit.cloudera.org:8080/21803
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I0d25d4c7fb0b8dcc7dad9510db1e8dca220eeb86
Gerrit-Change-Number: 21803
Gerrit-PatchSet: 42
Gerrit-Owner: Michael Smith <michael.sm...@cloudera.com>
Gerrit-Reviewer: Andrew Sherman <asher...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
Gerrit-Reviewer: Jason Fehr <jf...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <joemcdonn...@cloudera.com>
Gerrit-Reviewer: Michael Smith <michael.sm...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <huangquanl...@gmail.com>
Gerrit-Reviewer: Riza Suminto <riza.sumi...@cloudera.com>
Gerrit-Comment-Date: Thu, 17 Apr 2025 21:49:21 +0000
Gerrit-HasComments: Yes

Reply via email to