This is an automated email from the ASF dual-hosted git repository.
wyxxxcat 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 a1500f61f6b [improvement](cloud) Track compaction recycle rowset KV
puts and removals (#70801)
a1500f61f6b is described below
commit a1500f61f6b7fbcd1befb96d6f3715b9473dae95
Author: Yixuan Wang <[email protected]>
AuthorDate: Wed Dec 2 20:55:32 2026 +0800
[improvement](cloud) Track compaction recycle rowset KV puts and removals
(#70801)
### Background
Cloud compaction replaces its input rowsets and records them for
recycling.
Recycler uses these records to clean up obsolete rowsets and remove
their
recycle keys.
### What problem does this PR solve?
Issue Number: None
Related PR: None
PR Type: Enhancement
Problem Summary:
Cloud operators need per-instance counts to see how quickly compaction
adds
recycle keys and how quickly Recycler removes them. Add two cumulative
counters labeled by `instance_id` for successful operations on these
paths.
### Details
- **Before and after:** `compaction_recycle_rowset_kv_put_total` counts
direct recycle rowset KV puts after Meta Service commits the compaction
transaction. `compaction_recycle_rowset_kv_remove_total` counts
successful `COMPACT` recycle key removals in the batch and versioned
rowset scan paths.
- **Configs and defaults:** None.
- **Impact on existing users:** The counters are populated as matching
operations succeed and can be collected through the existing Cloud
metrics endpoints.
### Testing
Reviewed the commit diff. Runtime verification of the new counters is
pending.
### Notes for Reviewers
- With versioned writes, operation-log replay creates the recycle keys.
The versioned rowset scanner counts their later removal, so the put and
remove counters cover different sets of operations in this mode.
### Release note
Cloud metrics expose per-instance counters for direct compaction recycle
rowset KV puts and successful compaction recycle key removals.
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Partially verified: runtime counter values are
pending verification.
### AI Disclosure
- Tool: Codex (GPT-6)
- Generated: PR title and commit message
- Human review: not stated
---
cloud/src/common/bvars.cpp | 5 +++++
cloud/src/common/bvars.h | 3 +++
cloud/src/meta-service/meta_service_job.cpp | 12 ++++++++++--
cloud/src/recycler/recycler.cpp | 13 +++++++++++--
4 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/cloud/src/common/bvars.cpp b/cloud/src/common/bvars.cpp
index 63fcef02572..c35a4a57ffa 100644
--- a/cloud/src/common/bvars.cpp
+++ b/cloud/src/common/bvars.cpp
@@ -212,6 +212,11 @@ BvarStatusWithTag<int64_t>
g_bvar_recycler_batch_delete_rowset_plan_count(
BvarStatusWithTag<int64_t> g_bvar_recycler_batch_delete_failures(
"recycler", "batch_delete_failures");
+mBvarInt64Adder g_bvar_compaction_recycle_rowset_kv_put_total(
+ "compaction_recycle_rowset_kv_put_total", {"instance_id"});
+mBvarInt64Adder g_bvar_compaction_recycle_rowset_kv_remove_total(
+ "compaction_recycle_rowset_kv_remove_total", {"instance_id"});
+
// Operation Log Recycler BVars
mBvarStatus<int64_t> g_bvar_recycler_oplog_last_round_total_num(
"recycler_oplog_last_round_total_num", {"instance_id"});
diff --git a/cloud/src/common/bvars.h b/cloud/src/common/bvars.h
index 09b35c2775a..def66302590 100644
--- a/cloud/src/common/bvars.h
+++ b/cloud/src/common/bvars.h
@@ -747,6 +747,9 @@ extern BvarStatusWithTag<int64_t>
g_bvar_recycler_batch_delete_failures;
extern BvarStatusWithTag<int64_t>
g_bvar_recycler_packed_file_bytes_object_deleted;
extern BvarStatusWithTag<int64_t>
g_bvar_recycler_packed_file_rowset_scanned_num;
+extern mBvarInt64Adder g_bvar_compaction_recycle_rowset_kv_put_total;
+extern mBvarInt64Adder g_bvar_compaction_recycle_rowset_kv_remove_total;
+
// Operation Log Recycler BVars
// Note: generic metrics (last_round_to_recycle_num/bytes,
last_round_recycled_num/bytes, etc.)
// are reported by RecyclerMetricsContext with operation_type =
"recycle_operation_logs".
diff --git a/cloud/src/meta-service/meta_service_job.cpp
b/cloud/src/meta-service/meta_service_job.cpp
index a98cdcb90c5..f334257d1bc 100644
--- a/cloud/src/meta-service/meta_service_job.cpp
+++ b/cloud/src/meta-service/meta_service_job.cpp
@@ -1022,7 +1022,8 @@ void process_compaction_job(MetaServiceCode& code,
std::string& msg, std::string
FinishTabletJobResponse* response,
TabletJobInfoPB& recorded_job,
std::string& instance_id, std::string& job_key,
bool& need_commit,
std::string& use_version, bool is_versioned_read,
- bool is_versioned_write, TxnKv* txn_kv,
ResourceManager* resource_mgr) {
+ bool is_versioned_write, TxnKv* txn_kv,
ResourceManager* resource_mgr,
+ int64_t& compaction_recycle_rowset_kv_put_count) {
//==========================================================================
// check
//==========================================================================
@@ -1348,6 +1349,7 @@ void process_compaction_job(MetaServiceCode& code,
std::string& msg, std::string
} else {
auto recycle_val = recycle_rowset.SerializeAsString();
txn->put(recycle_key, recycle_val);
+ ++compaction_recycle_rowset_kv_put_count;
INSTANCE_LOG(INFO) << "put recycle rowset, tablet_id=" << tablet_id
<< " key=" << hex(recycle_key);
}
@@ -2218,11 +2220,13 @@ void _finish_tablet_job(const FinishTabletJobRequest*
request, FinishTabletJobRe
delete_bitmap_lock_white_list->get_delete_bitmap_lock_version(instance_id);
LOG(INFO) << "finish_tablet_job instance_id=" << instance_id
<< " use_version=" << use_version;
+ int64_t compaction_recycle_rowset_kv_put_count = 0;
if (!request->job().compaction().empty()) {
// Process compaction commit
process_compaction_job(code, msg, ss, txn, request, response,
recorded_job, instance_id,
job_key, need_commit, use_version,
is_versioned_read,
- is_versioned_write, txn_kv, resource_mgr);
+ is_versioned_write, txn_kv, resource_mgr,
+ compaction_recycle_rowset_kv_put_count);
} else if (request->job().has_schema_change()) {
// Process schema change commit
process_schema_change_job(code, msg, ss, txn, request, response,
recorded_job,
@@ -2260,6 +2264,10 @@ void _finish_tablet_job(const FinishTabletJobRequest*
request, FinishTabletJobRe
msg = ss.str();
return;
}
+ if (compaction_recycle_rowset_kv_put_count > 0) {
+ g_bvar_compaction_recycle_rowset_kv_put_total.put(
+ {instance_id}, compaction_recycle_rowset_kv_put_count);
+ }
break;
}
}
diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp
index 0bbb8eea93e..9732171808e 100644
--- a/cloud/src/recycler/recycler.cpp
+++ b/cloud/src/recycler/recycler.cpp
@@ -5833,6 +5833,7 @@ int InstanceRecycler::recycle_rowsets() {
};
std::vector<std::string> rowset_keys;
+ int64_t num_compacted_in_batch = 0;
std::vector<std::string> rowset_keys_to_mark_recycled;
std::vector<std::string> rowset_keys_to_abort_job;
// rowset_id -> rowset_meta
@@ -6004,7 +6005,9 @@ int InstanceRecycler::recycle_rowsets() {
return -1;
}
} else {
- num_compacted += rowset.type() == RecycleRowsetPB::COMPACT;
+ bool is_compacted = rowset.type() == RecycleRowsetPB::COMPACT;
+ num_compacted += is_compacted;
+ num_compacted_in_batch += is_compacted;
rowset_keys.emplace_back(k);
rowsets.emplace(rowset_meta->rowset_id_v2(),
std::move(*rowset_meta));
if (rowset_meta->num_segments() <= 0) { // Skip empty rowset
@@ -6025,6 +6028,7 @@ int InstanceRecycler::recycle_rowsets() {
std::vector<std::string> mark_keys_to_process;
std::vector<std::string> abort_job_keys_to_process;
rowset_keys_to_delete.swap(rowset_keys);
+ int64_t compacted_rowsets_to_delete =
std::exchange(num_compacted_in_batch, 0);
rowsets_to_delete.swap(rowsets);
mark_keys_to_process.swap(rowset_keys_to_mark_recycled);
abort_job_keys_to_process.swap(rowset_keys_to_abort_job);
@@ -6037,7 +6041,8 @@ int InstanceRecycler::recycle_rowsets() {
&num_recycled,
&metrics_context);
}
worker_pool->submit([&, rowset_keys_to_delete =
std::move(rowset_keys_to_delete),
- rowsets_to_delete =
std::move(rowsets_to_delete)]() mutable {
+ rowsets_to_delete = std::move(rowsets_to_delete),
+ compacted_rowsets_to_delete]() mutable {
std::vector<std::vector<std::string>>
versioned_delete_bitmap_key_groups;
if (delete_rowset_data(rowsets_to_delete,
RowsetRecyclingState::FORMAL_ROWSET,
metrics_context,
&versioned_delete_bitmap_key_groups) != 0) {
@@ -6056,6 +6061,10 @@ int InstanceRecycler::recycle_rowsets() {
return;
}
num_recycled.fetch_add(rowset_keys_to_delete.size(),
std::memory_order_relaxed);
+ if (compacted_rowsets_to_delete > 0) {
+
g_bvar_compaction_recycle_rowset_kv_remove_total.put({instance_id_},
+
compacted_rowsets_to_delete);
+ }
metrics_context.total_recycled_num.fetch_add(rowset_keys_to_delete.size(),
std::memory_order_relaxed);
metrics_context.report();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]