You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2018/05/17 03:28:51 UTC

kudu git commit: KUDU-2427: make ksck-test replica order deterministic

Repository: kudu
Updated Branches:
  refs/heads/master f57d73321 -> 5aca86284


KUDU-2427: make ksck-test replica order deterministic

On Ubuntu 18.04, the iteration order of std::unordered_map isn't the same as
on other distros. Behavioral changes like this are to be expected as the
iteration order is implementation-specific. However, we had some code in
ksck-test that expected a specific iteration order. Let's fix this by
switching from an std::unordered_map to an std::map.

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


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

Branch: refs/heads/master
Commit: 5aca86284967770048da6440b54ce0daea2d18eb
Parents: f57d733
Author: Adar Dembo <ad...@cloudera.com>
Authored: Sat May 12 10:57:30 2018 -0700
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Thu May 17 03:28:35 2018 +0000

----------------------------------------------------------------------
 src/kudu/tools/ksck-test.cc | 11 +++++++++--
 src/kudu/tools/ksck.h       |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/5aca8628/src/kudu/tools/ksck-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck-test.cc b/src/kudu/tools/ksck-test.cc
index 18db2ce..fd83ab5 100644
--- a/src/kudu/tools/ksck-test.cc
+++ b/src/kudu/tools/ksck-test.cc
@@ -17,6 +17,7 @@
 
 #include "kudu/tools/ksck.h"
 
+#include <algorithm>
 #include <cstdint>
 #include <map>
 #include <memory>
@@ -191,7 +192,7 @@ class KsckTest : public KuduTest {
       cluster_->masters_.push_back(master);
     }
 
-    unordered_map<string, shared_ptr<KsckTabletServer>> tablet_servers;
+    KsckCluster::TSMap tablet_servers;
     for (int i = 0; i < 3; i++) {
       string name = Substitute("ts-id-$0", i);
       shared_ptr<MockKsckTabletServer> ts(new MockKsckTabletServer(name));
@@ -223,8 +224,14 @@ class KsckTest : public KuduTest {
   }
 
   void CreateDefaultAssignmentPlan(int tablets_count) {
+    SCOPED_CLEANUP({
+        // This isn't necessary for correctness, but the tests were all
+        // written to expect a reversed order and doing that here is more
+        // convenient than rewriting many ASSERTs.
+        std::reverse(assignment_plan_.begin(), assignment_plan_.end());
+      })
     while (tablets_count > 0) {
-      for (const KsckCluster::TSMap::value_type& entry : cluster_->tablet_servers_) {
+      for (const auto& entry : cluster_->tablet_servers_) {
         if (tablets_count-- == 0) return;
         assignment_plan_.push_back(entry.second->uuid());
       }

http://git-wip-us.apache.org/repos/asf/kudu/blob/5aca8628/src/kudu/tools/ksck.h
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck.h b/src/kudu/tools/ksck.h
index 1c596e4..77b3d3c 100644
--- a/src/kudu/tools/ksck.h
+++ b/src/kudu/tools/ksck.h
@@ -357,7 +357,7 @@ class KsckCluster {
   typedef std::vector<std::shared_ptr<KsckMaster>> MasterList;
 
   // Map of KsckTabletServer objects keyed by tablet server uuid.
-  typedef std::unordered_map<std::string, std::shared_ptr<KsckTabletServer>> TSMap;
+  typedef std::map<std::string, std::shared_ptr<KsckTabletServer>> TSMap;
 
   // Fetches the lists of tables, tablets, and tablet servers from the master.
   Status FetchTableAndTabletInfo() {