From c8535a60b8465d271a380d27c3d0b6704e311eee Mon Sep 17 00:00:00 2001 From: Li0k Date: Wed, 8 Feb 2023 00:31:04 +0800 Subject: [PATCH] fix(storage): Distinguish between unssigned_task and tivival_move_task in the metrics report (#7742) In the existing code, if the assignee_context_id is not found, the corresponding task will be reported to the unassigned label, which is confusing. In this pr, it will distinguish trivival_move_task from unassigned more precisely so that they can be better distinguished in the metrics. Approved-By: Gun9niR Approved-By: zwang28 --- src/meta/src/hummock/manager/mod.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/meta/src/hummock/manager/mod.rs b/src/meta/src/hummock/manager/mod.rs index 9d1990b56ff96..24d7df88f577d 100644 --- a/src/meta/src/hummock/manager/mod.rs +++ b/src/meta/src/hummock/manager/mod.rs @@ -1182,7 +1182,7 @@ where } let task_status = compact_task.task_status(); - let task_label = task_status.as_str_name(); + let task_status_label = task_status.as_str_name(); if let Some(context_id) = assignee_context_id { // A task heartbeat is removed IFF we report the task status of a task and it still has // a valid assignment, OR we remove the node context from our list of nodes, @@ -1200,6 +1200,7 @@ where original_task_num: assigned_task_num, }); } + // Update compaction task count. // // A corner case is that the compactor is deleted @@ -1212,18 +1213,29 @@ where .with_label_values(&[ &format!("{}:{}", host.host, host.port), &compact_task.compaction_group_id.to_string(), - task_label, + task_status_label, ]) .inc(); } } else { - // Update compaction task count. The task will be marked as `unassigned`. + // There are two cases where assignee_context_id is not available + // 1. compactor does not exist + // 2. trivival_move + + let label = if CompactStatus::is_trivial_move_task(compact_task) { + // TODO: only support can_trivial_move in DynamicLevelCompcation, will check + // task_type next PR + "trivial-move" + } else { + "unassigned" + }; + self.metrics .compact_frequency .with_label_values(&[ - "unassigned", + label, &compact_task.compaction_group_id.to_string(), - task_label, + task_status_label, ]) .inc(); }