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

yiguolei pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 495d37d337 [fix](join) crash caused by canceling query (#16311) 
(#16349)
495d37d337 is described below

commit 495d37d33761f70565fac6978ee97a1df09e01a1
Author: Jerry Hu <mrh...@gmail.com>
AuthorDate: Thu Feb 2 16:17:17 2023 +0800

    [fix](join) crash caused by canceling query (#16311) (#16349)
    
    If the query was canceled,
    the status in shared context may be `OK` with other fields not set.
---
 be/src/vec/exec/join/vhash_join_node.cpp            |  3 ++-
 be/src/vec/runtime/shared_hash_table_controller.cpp | 11 +++++++++++
 be/src/vec/runtime/shared_hash_table_controller.h   |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/exec/join/vhash_join_node.cpp 
b/be/src/vec/exec/join/vhash_join_node.cpp
index 9f967a8190..9408622f78 100644
--- a/be/src/vec/exec/join/vhash_join_node.cpp
+++ b/be/src/vec/exec/join/vhash_join_node.cpp
@@ -1081,7 +1081,8 @@ std::vector<uint16_t> 
HashJoinNode::_convert_block_to_null(Block& block) {
 
 HashJoinNode::~HashJoinNode() {
     if (_shared_hashtable_controller && _should_build_hash_table) {
-        _shared_hashtable_controller->signal(id());
+        // signal at here is abnormal
+        _shared_hashtable_controller->signal(id(), Status::Cancelled("signaled 
in destructor"));
     }
 }
 
diff --git a/be/src/vec/runtime/shared_hash_table_controller.cpp 
b/be/src/vec/runtime/shared_hash_table_controller.cpp
index e9e125a168..e558798644 100644
--- a/be/src/vec/runtime/shared_hash_table_controller.cpp
+++ b/be/src/vec/runtime/shared_hash_table_controller.cpp
@@ -42,6 +42,17 @@ SharedHashTableContextPtr 
SharedHashTableController::get_context(int my_node_id)
     return _shared_contexts[my_node_id];
 }
 
+void SharedHashTableController::signal(int my_node_id, Status status) {
+    std::lock_guard<std::mutex> lock(_mutex);
+    auto it = _shared_contexts.find(my_node_id);
+    if (it != _shared_contexts.cend()) {
+        it->second->signaled = true;
+        it->second->status = status;
+        _shared_contexts.erase(it);
+    }
+    _cv.notify_all();
+}
+
 void SharedHashTableController::signal(int my_node_id) {
     std::lock_guard<std::mutex> lock(_mutex);
     auto it = _shared_contexts.find(my_node_id);
diff --git a/be/src/vec/runtime/shared_hash_table_controller.h 
b/be/src/vec/runtime/shared_hash_table_controller.h
index e2c54f533d..1b058dcebe 100644
--- a/be/src/vec/runtime/shared_hash_table_controller.h
+++ b/be/src/vec/runtime/shared_hash_table_controller.h
@@ -67,6 +67,7 @@ public:
     TUniqueId get_builder_fragment_instance_id(int my_node_id);
     SharedHashTableContextPtr get_context(int my_node_id);
     void signal(int my_node_id);
+    void signal(int my_node_id, Status status);
     Status wait_for_signal(RuntimeState* state, const 
SharedHashTableContextPtr& context);
     bool should_build_hash_table(const TUniqueId& fragment_instance_id, int 
my_node_id);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to