kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpe...@apache.org
Subject [2/2] kudu git commit: KUDU-1097. master: strip health reports from cstate before persisting
Date Sat, 02 Dec 2017 05:31:00 GMT
KUDU-1097. master: strip health reports from cstate before persisting

The master should not persist configs with health reports in them
because the health reports are inherently transient information.

This patch strips the health reports from the cstate included in each
leader tablet report before persisting them and adds a couple of DCHECKS
in random places to enforce that.

Change-Id: I3e0b076146d888d01676442f6ab3f67cca6bacd6
Reviewed-on: http://gerrit.cloudera.org:8080/8683
Reviewed-by: Alexey Serbin <aserbin@cloudera.com>
Tested-by: Kudu Jenkins
Reviewed-on: http://gerrit.cloudera.org:8080/8737


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

Branch: refs/heads/branch-1.6.x
Commit: d43404166c42c295b53aa195d19519bd9261aee7
Parents: 44b0bd2
Author: Mike Percy <mpercy@apache.org>
Authored: Wed Nov 29 04:25:12 2017 -0800
Committer: Mike Percy <mpercy@apache.org>
Committed: Sat Dec 2 05:30:40 2017 +0000

----------------------------------------------------------------------
 src/kudu/master/catalog_manager.cc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/d4340416/src/kudu/master/catalog_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index abfed16..acea922 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -3461,8 +3461,16 @@ Status CatalogManager::ProcessTabletReport(
             tablet_id, ts_desc->ToString(), cstate.committed_config().opid_index(),
             cstate.current_term());
 
+
         // 7d(ii). Update the consensus state.
-        *tablet->mutable_metadata()->mutable_dirty()->pb.mutable_consensus_state()
= cstate;
+        // Strip the health report from the cstate before persisting it.
+        auto* dirty_cstate =
+            tablet->mutable_metadata()->mutable_dirty()->pb.mutable_consensus_state();
+        *dirty_cstate = cstate; // Copy in the updated cstate.
+        // Strip out the health reports from the persisted copy *only*.
+        for (auto& peer : *dirty_cstate->mutable_committed_config()->mutable_peers())
{
+          peer.clear_health_report();
+        }
         tablet_was_mutated = true;
 
         // 7d(iii). Delete any replicas from the previous config that are not
@@ -3473,6 +3481,7 @@ Status CatalogManager::ProcessTabletReport(
             InsertOrDie(&current_member_uuids, p.permanent_uuid());
           }
           for (const auto& p : prev_cstate.committed_config().peers()) {
+            DCHECK(!p.has_health_report()); // Health report shouldn't be persisted.
             const string& peer_uuid = p.permanent_uuid();
             if (!ContainsKey(current_member_uuids, peer_uuid)) {
               rpcs.emplace_back(new AsyncDeleteReplica(
@@ -4044,6 +4053,7 @@ Status CatalogManager::BuildLocationsForTablet(
 
   const ConsensusStatePB& cstate = l_tablet.data().pb.consensus_state();
   for (const consensus::RaftPeerPB& peer : cstate.committed_config().peers()) {
+    DCHECK(!peer.has_health_report()); // Health report shouldn't be persisted.
     // TODO(adar): GetConsensusRole() iterates over all of the peers, making this an
     // O(n^2) loop. If replication counts get high, it should be optimized.
     switch (filter) {


Mime
View raw message