| 2017 | } |
| 2018 | |
| 2019 | Status ImpalaServer::KillQuery( |
| 2020 | const TUniqueId& query_id, const string& requesting_user, bool is_admin) { |
| 2021 | VLOG_QUERY << "KillQuery(): query_id=" << PrintId(query_id) |
| 2022 | << ", requesting_user=" << requesting_user << ", is_admin=" << is_admin; |
| 2023 | QueryHandle query_handle; |
| 2024 | RETURN_IF_ERROR(GetActiveQueryHandle(query_id, &query_handle)); |
| 2025 | if (!is_admin && requesting_user != query_handle->effective_user()) { |
| 2026 | return Status( |
| 2027 | Substitute("User '$0' is not authorized to kill the query.", requesting_user)); |
| 2028 | } |
| 2029 | Status status = CancelInternal(query_id); |
| 2030 | if (status.code() != TErrorCode::INVALID_QUERY_HANDLE) { |
| 2031 | // The current impalad is the coordinator of the query. |
| 2032 | RETURN_IF_ERROR(status); |
| 2033 | status = UnregisterQuery(query_id, &Status::CANCELLED, true); |
| 2034 | if (status.ok() || status.code() == TErrorCode::INVALID_QUERY_HANDLE) { |
| 2035 | // There might be another thread that has already unregistered the query |
| 2036 | // before UnregisterQuery() and after CancelInternal(). In this case we are done. |
| 2037 | return Status::OK(); |
| 2038 | } |
| 2039 | return status; |
| 2040 | } |
| 2041 | return status; |
| 2042 | } |
| 2043 | |
| 2044 | Status ImpalaServer::CloseSessionInternal(const TUniqueId& session_id, |
| 2045 | const SecretArg& secret, bool ignore_if_absent) { |
no test coverage detected