Skip to content

Commit

Permalink
[tablet] reinforce the CountLiveRows API
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Grant Henke <[email protected]>
  • Loading branch information
helifu authored and granthenke committed Jun 26, 2019
1 parent dcb8c39 commit 30b88b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/kudu/tablet/tablet-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/kudu/tablet/tablet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 30b88b4

Please sign in to comment.