kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject incubator-kudu git commit: ksck: usability improvements in error messages
Date Thu, 26 May 2016 14:38:32 GMT
Repository: incubator-kudu
Updated Branches:
  refs/heads/branch-0.9.x 9c8bf8b05 -> 1bd7d3c3d


ksck: usability improvements in error messages

- print the address of tablet servers that fail to connect
- print the table names of bad tablets

This doesn't lend itself to new test assertions, but I verified the
changes both against a real cluster and by inspecting the output
of 'ksck-test'.

Change-Id: I3cd6a6e0f82d03f890ac70af32814277dfd33c54
Reviewed-on: http://gerrit.cloudera.org:8080/3225
Reviewed-by: Jean-Daniel Cryans
Tested-by: Kudu Jenkins
(cherry picked from commit 3ab902eb33bb6f0d7e5ac56892ddcf4d0f1f1300)
Reviewed-on: http://gerrit.cloudera.org:8080/3226


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

Branch: refs/heads/branch-0.9.x
Commit: 1bd7d3c3d93cf666e2f2f8349c028cbf1fc993ec
Parents: 9c8bf8b
Author: Todd Lipcon <todd@apache.org>
Authored: Wed May 25 18:11:04 2016 -0700
Committer: Jean-Daniel Cryans <jdcryans@gerrit.cloudera.org>
Committed: Thu May 26 14:35:50 2016 +0000

----------------------------------------------------------------------
 src/kudu/tools/ksck-test.cc   | 27 ++++++++++++++-------------
 src/kudu/tools/ksck.cc        | 16 +++++++++-------
 src/kudu/tools/ksck.h         | 17 ++++++++++++++---
 src/kudu/tools/ksck_remote.cc | 10 +++++-----
 src/kudu/tools/ksck_remote.h  |  6 ++++--
 5 files changed, 46 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/1bd7d3c3/src/kudu/tools/ksck-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck-test.cc b/src/kudu/tools/ksck-test.cc
index 5cbdee0..4a3f221 100644
--- a/src/kudu/tools/ksck-test.cc
+++ b/src/kudu/tools/ksck-test.cc
@@ -128,43 +128,44 @@ class KsckTest : public KuduTest {
   void CreateOneTableOneTablet() {
     CreateDefaultAssignmentPlan(1);
 
-    shared_ptr<KsckTablet> tablet(new KsckTablet("1"));
+    auto table = CreateAndAddTable("test", 1);
+    shared_ptr<KsckTablet> tablet(new KsckTablet(table.get(), "1"));
     CreateAndFillTablet(tablet, 1, true);
-
-    CreateAndAddTable({ tablet }, "test", 1);
+    table->set_tablets({ tablet });
   }
 
   void CreateOneSmallReplicatedTable() {
     int num_replicas = 3;
     int num_tablets = 3;
-    vector<shared_ptr<KsckTablet>> tablets;
     CreateDefaultAssignmentPlan(num_replicas * num_tablets);
+    auto table = CreateAndAddTable("test", num_replicas);
+
+    vector<shared_ptr<KsckTablet>> tablets;
     for (int i = 0; i < num_tablets; i++) {
-      shared_ptr<KsckTablet> tablet(new KsckTablet(boost::lexical_cast<string>(i)));
+      shared_ptr<KsckTablet> tablet(new KsckTablet(table.get(), boost::lexical_cast<string>(i)));
       CreateAndFillTablet(tablet, num_replicas, true);
       tablets.push_back(tablet);
     }
-
-    CreateAndAddTable(tablets, "test", num_replicas);
+    table->set_tablets(tablets);
   }
 
   void CreateOneOneTabletReplicatedBrokenTable() {
     // We're placing only two tablets, the 3rd goes nowhere.
     CreateDefaultAssignmentPlan(2);
 
-    shared_ptr<KsckTablet> tablet(new KsckTablet("1"));
+    auto table = CreateAndAddTable("test", 3);
+
+    shared_ptr<KsckTablet> tablet(new KsckTablet(table.get(), "1"));
     CreateAndFillTablet(tablet, 2, false);
+    table->set_tablets({ tablet });
 
-    CreateAndAddTable({ tablet }, "test", 3);
   }
 
-  void CreateAndAddTable(vector<shared_ptr<KsckTablet>> tablets,
-                         const string& name, int num_replicas) {
+  shared_ptr<KsckTable> CreateAndAddTable(const string& name, int num_replicas)
{
     shared_ptr<KsckTable> table(new KsckTable(name, Schema(), num_replicas));
-    table->set_tablets(tablets);
-
     vector<shared_ptr<KsckTable>> tables = { table };
     master_->tables_.assign(tables.begin(), tables.end());
+    return table;
   }
 
   void CreateAndFillTablet(shared_ptr<KsckTablet>& tablet, int num_replicas, bool
has_leader) {

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/1bd7d3c3/src/kudu/tools/ksck.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck.cc b/src/kudu/tools/ksck.cc
index b1ff84a..922506d 100644
--- a/src/kudu/tools/ksck.cc
+++ b/src/kudu/tools/ksck.cc
@@ -158,8 +158,8 @@ Status Ksck::ConnectToTabletServer(const shared_ptr<KsckTabletServer>&
ts) {
   if (s.ok()) {
     VLOG(1) << "Connected to Tablet Server: " << ts->uuid();
   } else {
-    Warn() << Substitute("Unable to connect to Tablet Server $0 because $1",
-                         ts->uuid(), s.ToString()) << endl;
+    Warn() << Substitute("Unable to connect to Tablet Server $0 ($1) because $2",
+                         ts->uuid(), ts->address(), s.ToString()) << endl;
   }
   return s;
 }
@@ -458,11 +458,13 @@ bool Ksck::VerifyTable(const shared_ptr<KsckTable>& table)
{
 }
 
 bool Ksck::VerifyTablet(const shared_ptr<KsckTablet>& tablet, int table_num_replicas)
{
+  string tablet_str = Substitute("Tablet $0 of table '$1'",
+                                 tablet->id(), tablet->table()->name());
   vector<shared_ptr<KsckTabletReplica> > replicas = tablet->replicas();
   bool good_tablet = true;
   if (replicas.size() != table_num_replicas) {
-    Warn() << Substitute("Tablet $0 has $1 instead of $2 replicas",
-                         tablet->id(), replicas.size(), table_num_replicas) << endl;
+    Warn() << Substitute("$0 has $1 instead of $2 replicas",
+                         tablet_str, replicas.size(), table_num_replicas) << endl;
     // We only fail the "goodness" check if the tablet is under-replicated.
     if (replicas.size() < table_num_replicas) {
       good_tablet = false;
@@ -480,11 +482,11 @@ bool Ksck::VerifyTablet(const shared_ptr<KsckTablet>& tablet,
int table_num_repl
     }
   }
   if (leaders_count == 0) {
-    Warn() << Substitute("Tablet $0 doesn't have a leader", tablet->id()) <<
endl;
+    Warn() << Substitute("$0 doesn't have a leader", tablet_str) << endl;
     good_tablet = false;
   }
-  VLOG(1) << Substitute("Tablet $0 has $1 leader and $2 followers",
-                        tablet->id(), leaders_count, followers_count);
+  VLOG(1) << Substitute("$0 has $1 leader and $2 followers",
+                        tablet_str, leaders_count, followers_count);
   return good_tablet;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/1bd7d3c3/src/kudu/tools/ksck.h
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck.h b/src/kudu/tools/ksck.h
index f9d25a3..92e1951 100644
--- a/src/kudu/tools/ksck.h
+++ b/src/kudu/tools/ksck.h
@@ -35,6 +35,8 @@ namespace kudu {
 class MonoDelta;
 namespace tools {
 
+class KsckTable;
+
 // Options for checksum scans.
 struct ChecksumOptions {
  public:
@@ -94,7 +96,10 @@ class KsckTabletReplica {
 class KsckTablet {
  public:
   // TODO add start/end keys, stale.
-  explicit KsckTablet(std::string id) : id_(std::move(id)) {}
+  KsckTablet(KsckTable* table, std::string id)
+      : id_(std::move(id)),
+        table_(table) {
+  }
 
   const std::string& id() const {
     return id_;
@@ -107,9 +112,15 @@ class KsckTablet {
   void set_replicas(std::vector<std::shared_ptr<KsckTabletReplica> >& replicas)
{
     replicas_.assign(replicas.begin(), replicas.end());
   }
+
+  KsckTable* table() {
+    return table_;
+  }
+
  private:
   const std::string id_;
   std::vector<std::shared_ptr<KsckTabletReplica>> replicas_;
+  KsckTable* table_;
   DISALLOW_COPY_AND_ASSIGN(KsckTablet);
 };
 
@@ -131,8 +142,8 @@ class KsckTable {
     return num_replicas_;
   }
 
-  void set_tablets(std::vector<std::shared_ptr<KsckTablet>>& tablets) {
-    tablets_.assign(tablets.begin(), tablets.end());
+  void set_tablets(std::vector<std::shared_ptr<KsckTablet>> tablets) {
+    tablets_ = std::move(tablets);
   }
 
   std::vector<std::shared_ptr<KsckTablet> >& tablets() {

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/1bd7d3c3/src/kudu/tools/ksck_remote.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck_remote.cc b/src/kudu/tools/ksck_remote.cc
index 76c464c..e25e94d 100644
--- a/src/kudu/tools/ksck_remote.cc
+++ b/src/kudu/tools/ksck_remote.cc
@@ -277,14 +277,14 @@ Status RemoteKsckMaster::RetrieveTabletsList(const shared_ptr<KsckTable>&
table)
   bool more_tablets = true;
   string last_key;
   while (more_tablets) {
-    GetTabletsBatch(table->name(), &last_key, tablets, &more_tablets);
+    GetTabletsBatch(table, &last_key, tablets, &more_tablets);
   }
 
   table->set_tablets(tablets);
   return Status::OK();
 }
 
-Status RemoteKsckMaster::GetTabletsBatch(const string& table_name,
+Status RemoteKsckMaster::GetTabletsBatch(const shared_ptr<KsckTable>& table,
                                          string* last_partition_key,
                                          vector<shared_ptr<KsckTablet> >&
tablets,
                                          bool* more_tablets) {
@@ -292,14 +292,14 @@ Status RemoteKsckMaster::GetTabletsBatch(const string& table_name,
   master::GetTableLocationsResponsePB resp;
   RpcController rpc;
 
-  req.mutable_table()->set_table_name(table_name);
+  req.mutable_table()->set_table_name(table->name());
   req.set_max_returned_locations(FLAGS_tablets_batch_size_max);
   req.set_partition_key_start(*last_partition_key);
 
   rpc.set_timeout(GetDefaultTimeout());
   RETURN_NOT_OK(proxy_->GetTableLocations(req, &resp, &rpc));
   for (const master::TabletLocationsPB& locations : resp.tablet_locations()) {
-    shared_ptr<KsckTablet> tablet(new KsckTablet(locations.tablet_id()));
+    shared_ptr<KsckTablet> tablet(new KsckTablet(table.get(), locations.tablet_id()));
     vector<shared_ptr<KsckTabletReplica> > replicas;
     for (const master::TabletLocationsPB_ReplicaPB& replica : locations.replicas()) {
       bool is_leader = replica.role() == consensus::RaftPeerPB::LEADER;
@@ -315,7 +315,7 @@ Status RemoteKsckMaster::GetTabletsBatch(const string& table_name,
   } else {
     return Status::NotFound(Substitute(
       "The Master returned 0 tablets for GetTableLocations of table $0 at start key $1",
-      table_name, *(last_partition_key)));
+      table->name(), *(last_partition_key)));
   }
   if (last_partition_key->empty()) {
     *more_tablets = false;

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/1bd7d3c3/src/kudu/tools/ksck_remote.h
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck_remote.h b/src/kudu/tools/ksck_remote.h
index 4414038..5835b25 100644
--- a/src/kudu/tools/ksck_remote.h
+++ b/src/kudu/tools/ksck_remote.h
@@ -103,8 +103,10 @@ class RemoteKsckMaster : public KsckMaster {
   // seen last key that will be used as the new start key. The
   // last_partition_key is updated to point at the new last key that came in
   // the batch.
-  Status GetTabletsBatch(const std::string& table_name, std::string* last_partition_key,
-    std::vector<std::shared_ptr<KsckTablet> >& tablets, bool* more_tablets);
+  Status GetTabletsBatch(const std::shared_ptr<KsckTable>& table,
+                         std::string* last_partition_key,
+                         std::vector<std::shared_ptr<KsckTablet> >& tablets,
+                         bool* more_tablets);
 
   std::shared_ptr<rpc::Messenger> messenger_;
   std::shared_ptr<master::MasterServiceProxy> proxy_;


Mime
View raw message