This is an automated email from the ASF dual-hosted git repository.
zclllyybb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 886b0bb0e44 [fix](memory-tracker) Avoid nested task attach in cloud
snapshot manager (#63189)
886b0bb0e44 is described below
commit 886b0bb0e44a7770ce8776a26024de36d59e7700
Author: Qi Chen <[email protected]>
AuthorDate: Wed May 13 19:34:35 2026 +0800
[fix](memory-tracker) Avoid nested task attach in cloud snapshot manager
(#63189)
Cloud download callback already attaches the `SnapshotLoader` resource
context.
During cloud restore,` CloudSnapshotLoader::download()` calls
`CloudSnapshotMgr::make_snapshot()`, which previously used
`SCOPED_ATTACH_TASK`
again and could hit `ThreadContext::attach_task() `DCHECK because task
attach is
not nestable.
Use `SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER` in `CloudSnapshotMgr`
and`SnapshotMgr` snapshot
operations avoiding the nested-attach pattern. These methods only need
to
account memory to the manager tracker, and limiter switching works both
with
and without an outer attached task context.
---
be/src/cloud/cloud_snapshot_mgr.cpp | 6 +++---
be/src/storage/snapshot/snapshot_manager.cpp | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/be/src/cloud/cloud_snapshot_mgr.cpp
b/be/src/cloud/cloud_snapshot_mgr.cpp
index 01b65140996..8c676aa4f05 100644
--- a/be/src/cloud/cloud_snapshot_mgr.cpp
+++ b/be/src/cloud/cloud_snapshot_mgr.cpp
@@ -61,7 +61,7 @@ CloudSnapshotMgr::CloudSnapshotMgr(CloudStorageEngine&
engine) : _engine(engine)
Status CloudSnapshotMgr::make_snapshot(int64_t target_tablet_id,
StorageResource& storage_resource,
std::unordered_map<std::string,
std::string>& file_mapping,
bool is_restore, const Slice* slice) {
- SCOPED_ATTACH_TASK(_mem_tracker);
+ SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
if (is_restore && slice == nullptr) {
return Status::Error<INVALID_ARGUMENT>("slice cannot be null in
restore.");
}
@@ -105,7 +105,7 @@ Status CloudSnapshotMgr::make_snapshot(int64_t
target_tablet_id, StorageResource
}
Status CloudSnapshotMgr::commit_snapshot(int64_t tablet_id) {
- SCOPED_ATTACH_TASK(_mem_tracker);
+ SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
CloudTabletSPtr tablet =
DORIS_TRY(_engine.tablet_mgr().get_tablet(tablet_id));
if (tablet == nullptr) {
return Status::Error<TABLE_NOT_FOUND>("failed to get tablet.
tablet={}", tablet_id);
@@ -117,7 +117,7 @@ Status CloudSnapshotMgr::commit_snapshot(int64_t tablet_id)
{
}
Status CloudSnapshotMgr::release_snapshot(int64_t tablet_id, bool
is_completed) {
- SCOPED_ATTACH_TASK(_mem_tracker);
+ SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
RETURN_IF_ERROR(_engine.meta_mgr().finish_restore_job(tablet_id,
is_completed));
LOG(INFO) << "success to release snapshot. [tablet_id=" << tablet_id <<
"]";
return Status::OK();
diff --git a/be/src/storage/snapshot/snapshot_manager.cpp
b/be/src/storage/snapshot/snapshot_manager.cpp
index f5d16c9a158..0253602bd89 100644
--- a/be/src/storage/snapshot/snapshot_manager.cpp
+++ b/be/src/storage/snapshot/snapshot_manager.cpp
@@ -105,7 +105,7 @@ SnapshotManager::~SnapshotManager() = default;
Status SnapshotManager::make_snapshot(const TSnapshotRequest& request, string*
snapshot_path,
bool* allow_incremental_clone) {
- SCOPED_ATTACH_TASK(_mem_tracker);
+ SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
Status res = Status::OK();
if (snapshot_path == nullptr) {
return Status::Error<INVALID_ARGUMENT>("output parameter cannot be
null");
@@ -151,7 +151,7 @@ Status SnapshotManager::release_snapshot(const string&
snapshot_path) {
// If the requested snapshot_path is located in the root/snapshot folder,
it is considered legal and can be deleted.
// Otherwise, it is considered an illegal request and returns an error
result.
- SCOPED_ATTACH_TASK(_mem_tracker);
+ SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
auto stores = _engine.get_stores();
for (auto* store : stores) {
std::string abs_path;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]