kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From granthe...@apache.org
Subject [kudu] branch master updated: [tablet] reinforce the CountLiveRows API
Date Wed, 26 Jun 2019 18:09:25 GMT
This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 30b88b4  [tablet] reinforce the CountLiveRows API
30b88b4 is described below

commit 30b88b464f0b13ede2099832d40f50f4ed4a1b1b
Author: helifu <hzhelifu@corp.netease.com>
AuthorDate: Wed Jun 26 15:58:37 2019 +0800

    [tablet] reinforce the CountLiveRows API
    
    In the recent patch 13426, I found that the CountLiveRows API is
    not safe after the tablet is been shut down. Though the API has
    not been used by any real users except test cases, I think it's
    necessary to add this patch to the 1.10.x release in progress if
    it's possible.
    
    Change-Id: I56b25a6acb61564ce089be11a1605a19c25eb9e0
    Reviewed-on: http://gerrit.cloudera.org:8080/13734
    Tested-by: Kudu Jenkins
    Reviewed-by: Andrew Wong <awong@cloudera.com>
    Reviewed-by: Grant Henke <granthenke@apache.org>
---
 src/kudu/tablet/tablet-test.cc | 18 ++++++++++++++++++
 src/kudu/tablet/tablet.cc      |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/src/kudu/tablet/tablet-test.cc b/src/kudu/tablet/tablet-test.cc
index 27a0724..a42d268 100644
--- a/src/kudu/tablet/tablet-test.cc
+++ b/src/kudu/tablet/tablet-test.cc
@@ -901,6 +901,24 @@ TYPED_TEST(TestTablet, TestCompaction) {
   }
 }
 
+TYPED_TEST(TestTablet, TestCountLiveRowsAfterShutdown) {
+  // Insert 1000 rows into memrowset
+  uint64_t max_rows = this->ClampRowCount(FLAGS_testflush_num_inserts);
+  this->InsertTestRows(0, max_rows, 0);
+  ASSERT_OK(this->tablet()->Flush());
+  NO_FATALS(this->CheckLiveRowsCount(max_rows));
+
+  // Save the tablet's reference.
+  std::shared_ptr<Tablet> tablet = this->tablet();
+
+  // Shutdown the tablet.
+  NO_FATALS(this->tablet()->Shutdown());
+
+  // Call the CountLiveRows().
+  int64_t count = 0;
+  ASSERT_TRUE(tablet->CountLiveRows(&count).IsRuntimeError());
+}
+
 enum MutationType {
   MRS_MUTATION,
   DELTA_MUTATION,
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index 04e312c..c6489b5 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -1923,6 +1923,9 @@ Status Tablet::CountLiveRows(int64_t* count) const {
 
   scoped_refptr<TabletComponents> comps;
   GetComponents(&comps);
+  if (!comps) {
+    return Status::RuntimeError("The tablet has been shut down");
+  }
 
   int64_t ret = 0;
   int64_t tmp = 0;


Mime
View raw message