| 1103 | } |
| 1104 | |
| 1105 | void Coordinator::Cancel(bool wait_until_finalized) { |
| 1106 | // Illegal to call Cancel() before Exec() returns, so there's no danger of the cancel |
| 1107 | // RPC passing the exec RPC. |
| 1108 | DCHECK(exec_rpcs_complete_.Load()) << "Exec() must be called first"; |
| 1109 | discard_result(SetNonErrorTerminalState(ExecState::CANCELLED)); |
| 1110 | // CancelBackends() is called for all transitions into a terminal state. |
| 1111 | // RETURNED_RESULTS, however, calls it with fire_and_forget=false and may be blocked |
| 1112 | // waiting for cancellation. In that case, we want explicit cancellation to unblock |
| 1113 | // backend_exec_complete_barrier_, which we do by forcing cancellation. |
| 1114 | if (ReturnedAllResults()) CancelBackends(/*fire_and_forget=*/ true); |
| 1115 | |
| 1116 | // IMPALA-5756: Wait until finalized, in case a different thread was handling the |
| 1117 | // transition to the terminal state. |
| 1118 | if (wait_until_finalized) finalized_.Get(); |
| 1119 | } |
| 1120 | |
| 1121 | void Coordinator::CancelBackends(bool fire_and_forget) { |
| 1122 | int num_cancelled = 0; |