kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject [1/2] kudu git commit: KUDU-2159 Add metric for upserts converted to updates
Date Mon, 02 Oct 2017 19:09:05 GMT
Repository: kudu
Updated Branches:
  refs/heads/master bec2a2463 -> 5ca7deae7


KUDU-2159 Add metric for upserts converted to updates

This adds a metric tracking the number of successful upsert operations
that were applied as updates, per tablet, counting since server start.

Change-Id: Iefdee21fbfdfd3c9c8dca4c06d635b89bcf15d72
Reviewed-on: http://gerrit.cloudera.org:8080/8177
Tested-by: Kudu Jenkins
Reviewed-by: Will Berkeley <wdberkeley@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/3ec8834a
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/3ec8834a
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/3ec8834a

Branch: refs/heads/master
Commit: 3ec8834a43ba3ee5728fba0a3ed774c945279b7b
Parents: bec2a24
Author: Will Berkeley <wdberkeley@apache.org>
Authored: Fri Sep 29 11:01:16 2017 -0700
Committer: Will Berkeley <wdberkeley@gmail.com>
Committed: Mon Oct 2 16:30:48 2017 +0000

----------------------------------------------------------------------
 src/kudu/tablet/tablet-test.cc    | 11 +++++++++--
 src/kudu/tablet/tablet.cc         |  3 +++
 src/kudu/tablet/tablet_metrics.cc |  5 +++++
 src/kudu/tablet/tablet_metrics.h  |  1 +
 4 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/3ec8834a/src/kudu/tablet/tablet-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet-test.cc b/src/kudu/tablet/tablet-test.cc
index e5886be..3b9c954 100644
--- a/src/kudu/tablet/tablet-test.cc
+++ b/src/kudu/tablet/tablet-test.cc
@@ -53,6 +53,7 @@
 #include "kudu/tablet/tablet.h"
 #include "kudu/tablet/tablet.pb.h"
 #include "kudu/tablet/tablet_metadata.h"
+#include "kudu/tablet/tablet_metrics.h" // IWYU pragma: keep
 #include "kudu/util/faststring.h"
 #include "kudu/util/jsonwriter.h"
 #include "kudu/util/metrics.h"
@@ -719,10 +720,15 @@ TYPED_TEST(TestTablet, TestInsertsPersist) {
 
 TYPED_TEST(TestTablet, TestUpsert) {
   vector<string> rows;
+  const auto& upserts_as_updates = this->tablet()->metrics()->upserts_as_updates;
+
+  // Upsert a new row.
   this->UpsertTestRows(0, 1, 1000);
+  EXPECT_EQ(0, upserts_as_updates->value());
 
-  // UPSERT a row that is in MRS.
+  // Upsert a row that is in the MRS.
   this->UpsertTestRows(0, 1, 1001);
+  EXPECT_EQ(1, upserts_as_updates->value());
 
   ASSERT_OK(this->IterateToStringList(&rows));
   EXPECT_EQ(vector<string>{ this->setup_.FormatDebugRow(0, 1001, false) }, rows);
@@ -732,8 +738,9 @@ TYPED_TEST(TestTablet, TestUpsert) {
   ASSERT_OK(this->IterateToStringList(&rows));
   EXPECT_EQ(vector<string>{ this->setup_.FormatDebugRow(0, 1001, false) }, rows);
 
-  // UPSERT a row that is in DRS.
+  // Upsert a row that is in the DRS.
   this->UpsertTestRows(0, 1, 1002);
+  EXPECT_EQ(2, upserts_as_updates->value());
   ASSERT_OK(this->IterateToStringList(&rows));
   EXPECT_EQ(vector<string>{ this->setup_.FormatDebugRow(0, 1002, false) }, rows);
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/3ec8834a/src/kudu/tablet/tablet.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index 76fb887..0b16f07 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -611,6 +611,9 @@ Status Tablet::ApplyUpsertAsUpdate(WriteTransactionState* tx_state,
                                result.get());
   CHECK(!s.IsNotFound());
   if (s.ok()) {
+    if (metrics_) {
+      metrics_->upserts_as_updates->Increment();
+    }
     upsert->SetMutateSucceeded(std::move(result));
   } else {
     upsert->SetFailed(s);

http://git-wip-us.apache.org/repos/asf/kudu/blob/3ec8834a/src/kudu/tablet/tablet_metrics.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_metrics.cc b/src/kudu/tablet/tablet_metrics.cc
index d73ccd4..b5469e9 100644
--- a/src/kudu/tablet/tablet_metrics.cc
+++ b/src/kudu/tablet/tablet_metrics.cc
@@ -94,6 +94,10 @@ METRIC_DEFINE_counter(tablet, scanner_bytes_scanned_from_disk, "Scanner
Bytes Sc
 METRIC_DEFINE_counter(tablet, insertions_failed_dup_key, "Duplicate Key Inserts",
                       kudu::MetricUnit::kRows,
                       "Number of inserts which failed because the key already existed");
+METRIC_DEFINE_counter(tablet, upserts_as_updates, "Upserts converted into updates",
+                      kudu::MetricUnit::kRows,
+                      "Number of upserts which were applied as updates because the key already
"
+                      "existed.");
 METRIC_DEFINE_counter(tablet, scans_started, "Scans Started",
                       kudu::MetricUnit::kScanners,
                       "Number of scanners which have been started on this tablet");
@@ -263,6 +267,7 @@ TabletMetrics::TabletMetrics(const scoped_refptr<MetricEntity>&
entity)
     MINIT(rows_updated),
     MINIT(rows_deleted),
     MINIT(insertions_failed_dup_key),
+    MINIT(upserts_as_updates),
     MINIT(scanner_rows_returned),
     MINIT(scanner_cells_returned),
     MINIT(scanner_bytes_returned),

http://git-wip-us.apache.org/repos/asf/kudu/blob/3ec8834a/src/kudu/tablet/tablet_metrics.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_metrics.h b/src/kudu/tablet/tablet_metrics.h
index d7f3b38..6fa5a64 100644
--- a/src/kudu/tablet/tablet_metrics.h
+++ b/src/kudu/tablet/tablet_metrics.h
@@ -48,6 +48,7 @@ struct TabletMetrics {
   scoped_refptr<Counter> rows_updated;
   scoped_refptr<Counter> rows_deleted;
   scoped_refptr<Counter> insertions_failed_dup_key;
+  scoped_refptr<Counter> upserts_as_updates;
   scoped_refptr<Counter> scanner_rows_returned;
   scoped_refptr<Counter> scanner_cells_returned;
   scoped_refptr<Counter> scanner_bytes_returned;


Mime
View raw message