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

dataroaring pushed a commit to branch branch-4.0-preview
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 7721dabea9798ed8e513274ae9a60aaee5c0f354
Author: Xinyi Zou <[email protected]>
AuthorDate: Thu Apr 11 23:06:36 2024 +0800

    [fix](memory) Fix compaction destructor memory tracking #33549
---
 be/src/exec/rowid_fetcher.cpp       |  2 --
 be/src/olap/compaction.cpp          | 10 +++++++++-
 be/src/service/internal_service.cpp |  1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/be/src/exec/rowid_fetcher.cpp b/be/src/exec/rowid_fetcher.cpp
index 3892aac966a..c921be9509f 100644
--- a/be/src/exec/rowid_fetcher.cpp
+++ b/be/src/exec/rowid_fetcher.cpp
@@ -327,8 +327,6 @@ struct IteratorItem {
 
 Status RowIdStorageReader::read_by_rowids(const PMultiGetRequest& request,
                                           PMultiGetResponse* response) {
-    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(
-            ExecEnv::GetInstance()->rowid_storage_reader_tracker());
     // read from storage engine row id by row id
     OlapReaderStatistics stats;
     vectorized::Block result_block;
diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp
index 9f699fc3f89..a263d42ec6c 100644
--- a/be/src/olap/compaction.cpp
+++ b/be/src/olap/compaction.cpp
@@ -67,6 +67,7 @@
 #include "olap/txn_manager.h"
 #include "olap/utils.h"
 #include "runtime/memory/mem_tracker_limiter.h"
+#include "runtime/thread_context.h"
 #include "util/time.h"
 #include "util/trace.h"
 
@@ -120,7 +121,14 @@ Compaction::Compaction(BaseTabletSPtr tablet, const 
std::string& label)
     init_profile(label);
 }
 
-Compaction::~Compaction() = default;
+Compaction::~Compaction() {
+    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
+    _output_rs_writer.reset();
+    _tablet.reset();
+    _input_rowsets.clear();
+    _output_rowset.reset();
+    _cur_tablet_schema.reset();
+}
 
 void Compaction::init_profile(const std::string& label) {
     _profile = std::make_unique<RuntimeProfile>(label);
diff --git a/be/src/service/internal_service.cpp 
b/be/src/service/internal_service.cpp
index adcd81689c1..9918980514c 100644
--- a/be/src/service/internal_service.cpp
+++ b/be/src/service/internal_service.cpp
@@ -1926,6 +1926,7 @@ void 
PInternalService::multiget_data(google::protobuf::RpcController* controller
         watch.start();
         brpc::ClosureGuard closure_guard(done);
         response->mutable_status()->set_status_code(0);
+        
SCOPED_ATTACH_TASK(ExecEnv::GetInstance()->rowid_storage_reader_tracker());
         Status st = RowIdStorageReader::read_by_rowids(*request, response);
         st.to_protobuf(response->mutable_status());
         LOG(INFO) << "multiget_data finished, cost(us):" << 
watch.elapsed_time() / 1000;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to