You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by wz...@apache.org on 2021/11/17 16:51:50 UTC

[impala] 01/02: IMPALA-11006: Impalad crashes during query cancel tests

This is an automated email from the ASF dual-hosted git repository.

wzhou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 0cd5bb012856c364c2e7ec8962c01e488b718a8b
Author: Qifan Chen <qc...@cloudera.com>
AuthorDate: Thu Nov 4 19:44:13 2021 -0400

    IMPALA-11006: Impalad crashes during query cancel tests
    
    This patch addresses impalad crash during query cancel tests for
    CTAS. The root cause is that the wait thread in impalad assumes
    that the coordinator or computation results are always available
    once the worker thread async_exec_thread_ is joined. In reality,
    this never happens as the query is cancelled.
    
    The patch specifically checks the cancel status when it is found
    that the coordinator is not available for CTAS and bails out
    immediately. This prevents crash since the subsequent code that
    assumes the coordinator or computation results are available is
    never reached.
    
    Testing:
      1. Ran core tests successfully.
    
    Change-Id: Ia49411f8525734b8d463d9ffbfbce705b90a8d73
    Reviewed-on: http://gerrit.cloudera.org:8080/17999
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/service/client-request-state.cc | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/be/src/service/client-request-state.cc b/be/src/service/client-request-state.cc
index 7939c5f..ca0f6c0 100644
--- a/be/src/service/client-request-state.cc
+++ b/be/src/service/client-request-state.cc
@@ -1060,6 +1060,9 @@ Status ClientRequestState::WaitInternal() {
   }
   if (!child_queries.empty()) query_events_->MarkEvent("Child queries finished");
 
+  bool isCTAS = catalog_op_type() == TCatalogOpType::DDL
+      && ddl_type() == TDdlType::CREATE_TABLE_AS_SELECT;
+
   if (GetCoordinator() != NULL) {
     Status status = GetCoordinator()->Wait();
     if (UNLIKELY(!status.ok())) {
@@ -1067,6 +1070,14 @@ Status ClientRequestState::WaitInternal() {
       return status;
     }
     RETURN_IF_ERROR(UpdateCatalog());
+  } else {
+    // When the coordinator is not available for CTAS that requires a coordinator, check
+    // further if the query has been cancelled. If so, return immediately as there will
+    // be no query result available (IMPALA-11006).
+    if (isCTAS) {
+      lock_guard<mutex> l(lock_);
+      if (is_cancelled_) return Status::CANCELLED;
+    }
   }
 
   if (catalog_op_type() == TCatalogOpType::DDL &&
@@ -1078,8 +1089,7 @@ Status ClientRequestState::WaitInternal() {
     // Queries that do not return a result are finished at this point. This includes
     // DML operations.
     eos_.Store(true);
-  } else if (catalog_op_type() == TCatalogOpType::DDL &&
-      ddl_type() == TDdlType::CREATE_TABLE_AS_SELECT) {
+  } else if (isCTAS) {
     SetCreateTableAsSelectResultSet();
   }
   // Rows are available now (for SELECT statement), so start the 'wait' timer that tracks