You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ca...@apache.org on 2022/10/08 14:26:38 UTC

[doris] branch branch-1.1-lts updated: [fix](ut) Fix ut affected by MemTracker #13187

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

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


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new a7ab67a47c [fix](ut) Fix ut affected by MemTracker #13187
a7ab67a47c is described below

commit a7ab67a47cd9dc60227f1aaa612f3bf0fed16413
Author: Xinyi Zou <zo...@gmail.com>
AuthorDate: Sat Oct 8 22:26:32 2022 +0800

    [fix](ut) Fix ut affected by MemTracker #13187
    
    fix json_scanner_test,json_scanner_with_jsonpath_test,broker_scan_node_test,es_http_scan_node_test
    mem_limit_test failure
---
 be/src/runtime/memory/mem_tracker_task_pool.cpp | 8 ++++++++
 be/src/runtime/thread_context.cpp               | 9 +++++++++
 2 files changed, 17 insertions(+)

diff --git a/be/src/runtime/memory/mem_tracker_task_pool.cpp b/be/src/runtime/memory/mem_tracker_task_pool.cpp
index 143e7486fa..c4f9ba2dd7 100644
--- a/be/src/runtime/memory/mem_tracker_task_pool.cpp
+++ b/be/src/runtime/memory/mem_tracker_task_pool.cpp
@@ -47,17 +47,25 @@ std::shared_ptr<MemTrackerLimiter> MemTrackerTaskPool::register_task_mem_tracker
 
 std::shared_ptr<MemTrackerLimiter> MemTrackerTaskPool::register_query_mem_tracker(
         const std::string& query_id, int64_t mem_limit) {
+#ifndef BE_TEST
     return register_task_mem_tracker_impl(query_id, mem_limit,
                                           fmt::format("Query#queryId={}", query_id),
                                           ExecEnv::GetInstance()->query_pool_mem_tracker());
+#else
+    return std::make_shared<doris::MemTrackerLimiter>(mem_limit, query_id);
+#endif // BE_TEST
 }
 
 std::shared_ptr<MemTrackerLimiter> MemTrackerTaskPool::register_load_mem_tracker(
         const std::string& load_id, int64_t mem_limit) {
+#ifndef BE_TEST
     // In load, the query id of the fragment is executed, which is the same as the load id of the load channel.
     return register_task_mem_tracker_impl(load_id, mem_limit,
                                           fmt::format("Load#queryId={}", load_id),
                                           ExecEnv::GetInstance()->load_pool_mem_tracker());
+#else
+    return std::make_shared<doris::MemTrackerLimiter>(mem_limit, load_id);
+#endif // BE_TEST
 }
 
 std::shared_ptr<MemTrackerLimiter> MemTrackerTaskPool::get_task_mem_tracker(
diff --git a/be/src/runtime/thread_context.cpp b/be/src/runtime/thread_context.cpp
index 82713f0f50..b993308db8 100644
--- a/be/src/runtime/thread_context.cpp
+++ b/be/src/runtime/thread_context.cpp
@@ -58,6 +58,15 @@ AttachTask::AttachTask(RuntimeState* runtime_state) {
             query_to_task_type(runtime_state->query_type()), print_id(runtime_state->query_id()),
             runtime_state->fragment_instance_id(), runtime_state->new_instance_mem_tracker());
 #endif // USE_MEM_TRACKER
+#else
+    if (ExecEnv::GetInstance()->new_process_mem_tracker() == nullptr) {
+        std::shared_ptr<MemTrackerLimiter> process_mem_tracker =
+            std::make_shared<MemTrackerLimiter>(-1, "Process");
+        std::shared_ptr<MemTrackerLimiter> _orphan_mem_tracker =
+                std::make_shared<MemTrackerLimiter>(-1, "Orphan", process_mem_tracker);
+        ExecEnv::GetInstance()->set_global_mem_tracker(process_mem_tracker, _orphan_mem_tracker);
+    }
+    thread_context()->attach_task(ThreadContext::TaskType::QUERY, "", TUniqueId(), ExecEnv::GetInstance()->orphan_mem_tracker());
 #endif // BE_TEST
 }
 


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