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

alexey pushed a commit to branch branch-1.11.x
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 5e3e82b3a9b653dd24d4ec856cf4aaf66882cd17
Author: zhangyifan27 <[email protected]>
AuthorDate: Tue Oct 15 19:21:38 2019 +0800

    master: fix the value of table metric 'live_row_count'
    
    When the tablet doesn't support live row counting, the
    'live_row_count' metric of the tablet is '-1'. But when
    master aggregates all tablets' metric of a table, it sums
    up all '-1's, and the result value is confusing to users.
    It's better to set it '-1' to be consistent with tablet metric.
    
    Change-Id: I3f837466a0420dafef4f9426929b7b1622702ffc
    Reviewed-on: http://gerrit.cloudera.org:8080/14446
    Tested-by: Kudu Jenkins
    Reviewed-by: Yingchun Lai <[email protected]>
    Reviewed-by: Alexey Serbin <[email protected]>
    (cherry picked from commit d525c11d441143eeb40389ab920f5f651ddff54f)
    Reviewed-on: http://gerrit.cloudera.org:8080/14468
    Tested-by: Alexey Serbin <[email protected]>
    Reviewed-by: Grant Henke <[email protected]>
---
 src/kudu/master/catalog_manager.cc | 7 ++++++-
 src/kudu/master/table_metrics.cc   | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/kudu/master/catalog_manager.cc 
b/src/kudu/master/catalog_manager.cc
index 6108981..411906c 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -5573,7 +5573,12 @@ void TableInfo::UpdateMetrics(const 
tablet::ReportedTabletStatsPB& old_stats,
                               const tablet::ReportedTabletStatsPB& new_stats) {
   if (metrics_) {
     metrics_->on_disk_size->IncrementBy(new_stats.on_disk_size() - 
old_stats.on_disk_size());
-    metrics_->live_row_count->IncrementBy(new_stats.live_row_count() - 
old_stats.live_row_count());
+    if (new_stats.live_row_count() >= 0) {
+      metrics_->live_row_count->IncrementBy(
+          new_stats.live_row_count() - old_stats.live_row_count());
+    } else {
+      metrics_->live_row_count->set_value(-1);
+    }
   }
 }
 
diff --git a/src/kudu/master/table_metrics.cc b/src/kudu/master/table_metrics.cc
index 079379a..b259034 100644
--- a/src/kudu/master/table_metrics.cc
+++ b/src/kudu/master/table_metrics.cc
@@ -27,7 +27,8 @@ METRIC_DEFINE_gauge_int64(table, on_disk_size, "Table Size On 
Disk",
     "including metadata.");
 METRIC_DEFINE_gauge_int64(table, live_row_count, "Table Live Row count",
     kudu::MetricUnit::kRows,
-    "Pre-replication aggregated number of live rows in this table.");
+    "Pre-replication aggregated number of live rows in this table. "
+    "When the table doesn't support live row counting, -1 will be returned.");
 
 #define GINIT(x) x(METRIC_##x.Instantiate(entity, 0))
 

Reply via email to