This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new f63a43f037f branch-4.0: [fix](recycler) Fix metrics statistics issues
in recycler workflows #60697 (#60933)
f63a43f037f is described below
commit f63a43f037f4e9c8c9400ed579da231e3e7fdff0
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Mar 2 10:06:50 2026 +0800
branch-4.0: [fix](recycler) Fix metrics statistics issues in recycler
workflows #60697 (#60933)
Cherry-picked from #60697
Co-authored-by: Yixuan Wang <[email protected]>
---
cloud/src/recycler/recycler.cpp | 32 +++++++++++++++++++++-----------
cloud/src/recycler/recycler.h | 8 ++++----
2 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp
index 67484c81605..dec78545f0f 100644
--- a/cloud/src/recycler/recycler.cpp
+++ b/cloud/src/recycler/recycler.cpp
@@ -3535,8 +3535,6 @@ int InstanceRecycler::delete_rowset_data(
metrics_context.total_recycled_num++;
}
});
- segment_metrics_context_.report();
- metrics_context.report();
}
return ret;
});
@@ -3554,8 +3552,6 @@ int InstanceRecycler::delete_rowset_data(
metrics_context.total_recycled_num++;
segment_metrics_context_.total_recycled_data_size +=
rs.total_disk_size();
segment_metrics_context_.total_recycled_num +=
rs.num_segments();
- metrics_context.report();
- segment_metrics_context_.report();
}
return ret;
});
@@ -3991,8 +3987,6 @@ int InstanceRecycler::recycle_tablet(int64_t tablet_id,
RecyclerMetricsContext&
concurrent_delete_executor.add(
[&, rs_id = resource_id,
accessor_ptr = accessor_map_[resource_id]]() ->
decltype(auto) {
- std::unique_ptr<int, std::function<void(int*)>> defer(
- (int*)0x01, [&](int*) { metrics_context.report();
});
int res =
accessor_ptr->delete_directory(tablet_path_prefix(tablet_id));
if (res != 0) {
LOG(WARNING) << "failed to delete rowset data of
tablet " << tablet_id
@@ -4596,8 +4590,6 @@ int InstanceRecycler::recycle_rowsets() {
segment_metrics_context_.total_recycled_data_size +=
rowset.rowset_meta().total_disk_size();
segment_metrics_context_.total_recycled_num +=
rowset.rowset_meta().num_segments();
- segment_metrics_context_.report();
- metrics_context.report();
return 0;
}
@@ -4721,6 +4713,11 @@ int InstanceRecycler::recycle_rowsets() {
num_recycled.fetch_add(async_recycled_rowset_keys.size(),
std::memory_order_relaxed);
}
}
+
+ // Report final metrics after all concurrent tasks completed
+ segment_metrics_context_.report();
+ metrics_context.report();
+
return ret;
}
@@ -5125,6 +5122,11 @@ int InstanceRecycler::recycle_versioned_rowsets() {
num_recycled.fetch_add(async_recycled_rowset_keys.size(),
std::memory_order_relaxed);
}
}
+
+ // Report final metrics after all concurrent tasks completed
+ segment_metrics_context_.report();
+ metrics_context.report();
+
return ret;
}
@@ -5468,6 +5470,11 @@ int InstanceRecycler::recycle_tmp_rowsets() {
std::move(loop_done));
worker_pool->stop();
+
+ // Report final metrics after all concurrent tasks completed
+ segment_metrics_context_.report();
+ metrics_context.report();
+
return ret;
}
@@ -5681,7 +5688,7 @@ int InstanceRecycler::recycle_expired_txn_label() {
const std::string task_name = "recycle_expired_txn_label";
int64_t num_scanned = 0;
int64_t num_expired = 0;
- int64_t num_recycled = 0;
+ std::atomic_long num_recycled = 0;
RecyclerMetricsContext metrics_context(instance_id_, task_name);
int ret = 0;
@@ -5833,8 +5840,7 @@ int InstanceRecycler::recycle_expired_txn_label() {
LOG(WARNING) << "failed to delete expired txn, err=" << err << "
key=" << hex(k);
return -1;
}
- metrics_context.total_recycled_num = ++num_recycled;
- metrics_context.report();
+ ++num_recycled;
LOG(INFO) << "recycle expired txn, key=" << hex(k);
return 0;
@@ -5885,6 +5891,10 @@ int InstanceRecycler::recycle_expired_txn_label() {
ret = finished ? ret : -1;
+ // Update metrics after all concurrent tasks completed
+ metrics_context.total_recycled_num = num_recycled.load();
+ metrics_context.report();
+
TEST_SYNC_POINT_CALLBACK("InstanceRecycler::recycle_expired_txn_label.failure",
&ret);
if (ret != 0) {
diff --git a/cloud/src/recycler/recycler.h b/cloud/src/recycler/recycler.h
index d8bd137f3dc..68432ff7c77 100644
--- a/cloud/src/recycler/recycler.h
+++ b/cloud/src/recycler/recycler.h
@@ -192,6 +192,10 @@ public:
g_bvar_recycler_instance_last_round_recycle_elpased_ts.put(
{instance_id, operation_type}, cost);
g_bvar_recycler_instance_recycle_round.put({instance_id,
operation_type}, 1);
+ g_bvar_recycler_instance_recycle_total_bytes_since_started.put(
+ {instance_id, operation_type},
total_recycled_data_size.load());
+ g_bvar_recycler_instance_recycle_total_num_since_started.put(
+ {instance_id, operation_type}, total_recycled_num.load());
LOG(INFO) << "recycle instance: " << instance_id
<< ", operation type: " << operation_type << ", cost: "
<< cost
<< " ms, total recycled num: " <<
total_recycled_num.load()
@@ -222,12 +226,8 @@ public:
} else {
g_bvar_recycler_instance_last_round_recycled_bytes.put(
{instance_id, operation_type},
total_recycled_data_size.load());
- g_bvar_recycler_instance_recycle_total_bytes_since_started.put(
- {instance_id, operation_type},
total_recycled_data_size.load());
g_bvar_recycler_instance_last_round_recycled_num.put({instance_id,
operation_type},
total_recycled_num.load());
- g_bvar_recycler_instance_recycle_total_num_since_started.put(
- {instance_id, operation_type},
total_recycled_num.load());
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]