wangbo commented on code in PR #30829:
URL: https://github.com/apache/doris/pull/30829#discussion_r1478116727


##########
be/src/runtime/task_group/task_group.h:
##########
@@ -142,13 +142,22 @@ class TaskGroup : public 
std::enable_shared_from_this<TaskGroup> {
         return _memory_limit > 0;
     }
 
-    void add_query(TUniqueId query_id) { _query_id_set.insert(query_id); }
+    void add_query(TUniqueId query_id) {
+        std::unique_lock<std::shared_mutex> wlock(_mutex);
+        _query_id_set.insert(query_id);
+    }
 
-    void remove_query(TUniqueId query_id) { _query_id_set.erase(query_id); }
+    void remove_query(TUniqueId query_id) {
+        std::unique_lock<std::shared_mutex> wlock(_mutex);
+        _query_id_set.erase(query_id);
+    }
 
     void shutdown() { _is_shutdown = true; }
 
-    int query_num() { return _query_id_set.size(); }
+    int query_num() {
+        std::shared_lock<std::shared_mutex> r_lock(_mutex);
+        return _query_id_set.size();
+    }
 
     bool is_shutdown() { return _is_shutdown; }

Review Comment:
   You'd better drop task group's shutdown as well



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to