You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by mp...@apache.org on 2018/05/08 16:42:55 UTC

[1/2] kudu git commit: thirdparty: build llvm against thirdparty zlib

Repository: kudu
Updated Branches:
  refs/heads/master 3d344ecef -> e7ee66786


thirdparty: build llvm against thirdparty zlib

Turns out we already have zlib in thirdparty, so let's use it when building
LLVM. For some reason LLVM doesn't actually enable zlib support (i.e. the
llvm::zlib functions in libLLVMSupport.a are still stubs), but this lets
IWYU build even if the host doesn't have zlib-devel installed.

Change-Id: I5fdae9c77e7d8b6d11b6dc2997686bbdbb383301
Reviewed-on: http://gerrit.cloudera.org:8080/10311
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>


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

Branch: refs/heads/master
Commit: 17b443fa005ae17d2c493b198e10bb876e493343
Parents: 3d344ec
Author: Adar Dembo <ad...@cloudera.com>
Authored: Fri May 4 12:51:42 2018 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue May 8 15:22:58 2018 +0000

----------------------------------------------------------------------
 thirdparty/build-definitions.sh | 10 +++++++++-
 thirdparty/preflight.py         | 12 ------------
 2 files changed, 9 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/17b443fa/thirdparty/build-definitions.sh
----------------------------------------------------------------------
diff --git a/thirdparty/build-definitions.sh b/thirdparty/build-definitions.sh
index 575eae9..fe3f477 100644
--- a/thirdparty/build-definitions.sh
+++ b/thirdparty/build-definitions.sh
@@ -307,6 +307,14 @@ build_llvm() {
   # handles this when passing --stdlib=libc++ and passing this confuses
   # the check for -fPIC.
   CLANG_CXXFLAGS=$(echo "$EXTRA_CXXFLAGS" | sed -e 's,-nostdinc++,,g;')
+
+  # Depend on zlib from the thirdparty tree. It's an optional dependency for
+  # LLVM, but a required [1] one for IWYU.
+  #
+  # 1. https://github.com/include-what-you-use/include-what-you-use/issues/539
+  CLANG_CXXFLAGS="$CLANG_CXXFLAGS -I$PREFIX/include"
+  CLANG_LDFLAGS="$EXTRA_LDFLAGS -L$PREFIX/lib -Wl,-rpath,$PREFIX/lib"
+
   cmake \
     -DCMAKE_BUILD_TYPE=Release \
     -DCMAKE_INSTALL_PREFIX=$PREFIX \
@@ -316,7 +324,7 @@ build_llvm() {
     -DLLVM_INCLUDE_UTILS=OFF \
     -DLLVM_TARGETS_TO_BUILD=X86 \
     -DLLVM_ENABLE_RTTI=ON \
-    -DCMAKE_CXX_FLAGS="$CLANG_CXXFLAGS $EXTRA_LDFLAGS" \
+    -DCMAKE_CXX_FLAGS="$CLANG_CXXFLAGS $CLANG_LDFLAGS" \
     -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
     $TOOLS_ARGS \
     $EXTRA_CMAKE_FLAGS \

http://git-wip-us.apache.org/repos/asf/kudu/blob/17b443fa/thirdparty/preflight.py
----------------------------------------------------------------------
diff --git a/thirdparty/preflight.py b/thirdparty/preflight.py
index 85cc42b..cb77325 100755
--- a/thirdparty/preflight.py
+++ b/thirdparty/preflight.py
@@ -142,17 +142,6 @@ def check_openssl():
       """,
       flags=["-E"]))
 
-def check_zlib():
-  try_do(
-    "Checking for zlib headers",
-    ("Unable to compile a simple program that uses zlib. " +
-     "Please check that zlib-devel (RPM) or zlib1g-dev (deb) " +
-     "dependencies are installed."),
-    lambda: compile("""
-      #include <zlib.h>
-      """,
-      flags=["-E"]))
-
 def main():
   print("Running pre-flight checks")
   print("-------------------------")
@@ -165,7 +154,6 @@ def main():
   check_cxx11()
   check_sasl()
   check_openssl()
-  check_zlib()
   print("-------------")
   print("Pre-flight checks succeeded.")
   return 0


[2/2] kudu git commit: consensus: include peer address in leader election messages

Posted by mp...@apache.org.
consensus: include peer address in leader election messages

This additional info makes it easier to read and interpret consensus
traffic in log messages.

The new log lines look like this:

  I0507 18:16:21.487584  1667 raft_consensus.cc:457] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877 [term 0 FOLLOWER]: Starting pre-election with config: opid_index: -1 OBSOLETE_local: false peers { permanent_uuid: "ad85c27590a848a2bdd89684da1db336" member_type: VOTER last_known_addr { host: "127.1.68.1" port: 44207 } } peers { permanent_uuid: "c2e1ad2aaffb48b08e018b4999c45612" member_type: VOTER last_known_addr { host: "127.1.68.2" port: 46305 } } peers { permanent_uuid: "e8523a05f7dd4d90977c7ccf00cb0877" member_type: VOTER last_known_addr { host: "127.1.68.4" port: 46653 } }
  I0507 18:16:21.487962  1667 leader_election.cc:243] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877 [CANDIDATE]: Term 1 pre-election: Requesting pre-vote from peer ad85c27590a848a2bdd89684da1db336 (127.1.68.1:44207)
  I0507 18:16:21.488155  1667 leader_election.cc:243] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877 [CANDIDATE]: Term 1 pre-election: Requesting pre-vote from peer c2e1ad2aaffb48b08e018b4999c45612 (127.1.68.2:46305)
  I0507 18:16:21.491686  1410 tablet_service.cc:998] Received RequestConsensusVote() RPC: tablet_id: "6854ca4380c24f3a865458747235c4a3" candidate_uuid: "e8523a05f7dd4d90977c7ccf00cb0877" candidate_term: 1 candidate_status { last_received { term: 0 index: 0 } } ignore_live_leader: false dest_uuid: "ad85c27590a848a2bdd89684da1db336" is_pre_election: true
  I0507 18:16:21.491680  1470 tablet_service.cc:998] Received RequestConsensusVote() RPC: tablet_id: "6854ca4380c24f3a865458747235c4a3" candidate_uuid: "e8523a05f7dd4d90977c7ccf00cb0877" candidate_term: 1 candidate_status { last_received { term: 0 index: 0 } } ignore_live_leader: false dest_uuid: "c2e1ad2aaffb48b08e018b4999c45612" is_pre_election: true
  I0507 18:16:21.491806  1410 raft_consensus.cc:2704] T 6854ca4380c24f3a865458747235c4a3 P ad85c27590a848a2bdd89684da1db336: Snoozing failure detection for 1.976s (vote granted)
  I0507 18:16:21.491806  1470 raft_consensus.cc:2704] T 6854ca4380c24f3a865458747235c4a3 P c2e1ad2aaffb48b08e018b4999c45612: Snoozing failure detection for 1.870s (vote granted)
  I0507 18:16:21.491855  1470 raft_consensus.cc:2219] T 6854ca4380c24f3a865458747235c4a3 P c2e1ad2aaffb48b08e018b4999c45612 [term 0 FOLLOWER]: Leader pre-election vote request: Granting yes vote for candidate e8523a05f7dd4d90977c7ccf00cb0877 in term 0.
  I0507 18:16:21.491855  1410 raft_consensus.cc:2219] T 6854ca4380c24f3a865458747235c4a3 P ad85c27590a848a2bdd89684da1db336 [term 0 FOLLOWER]: Leader pre-election vote request: Granting yes vote for candidate e8523a05f7dd4d90977c7ccf00cb0877 in term 0.
  I0507 18:16:21.492164  1576 leader_election.cc:379] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877 [CANDIDATE]: Term 1 pre-election: Vote granted by peer ad85c27590a848a2bdd89684da1db336 (127.1.68.1:44207)
  I0507 18:16:21.492213  1576 leader_election.cc:270] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877 [CANDIDATE]: Term 1 pre-election: Election decided. Result: candidate won.
  I0507 18:16:21.492254  1578 leader_election.cc:379] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877 [CANDIDATE]: Term 1 pre-election: Vote granted by peer c2e1ad2aaffb48b08e018b4999c45612 (127.1.68.2:46305)
  I0507 18:16:21.492349  1667 raft_consensus.cc:2704] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877: Snoozing failure detection for 1.884s (election complete)
  I0507 18:16:21.492388  1667 raft_consensus.cc:2511] T 6854ca4380c24f3a865458747235c4a3 P e8523a05f7dd4d90977c7ccf00cb0877 [term 0 FOLLOWER]: Leader pre-election won for term 1

Change-Id: I2ec311bb6d892a42f64a77ebbde6e6d5ddf68724
Reviewed-on: http://gerrit.cloudera.org:8080/10338
Tested-by: Mike Percy <mp...@apache.org>
Reviewed-by: Todd Lipcon <to...@apache.org>
Reviewed-by: Alexey Serbin <as...@cloudera.com>


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

Branch: refs/heads/master
Commit: e7ee667868af798015936cad94173d9779d6b470
Parents: 17b443f
Author: Mike Percy <mp...@apache.org>
Authored: Mon May 7 17:49:16 2018 -0700
Committer: Mike Percy <mp...@apache.org>
Committed: Tue May 8 16:42:35 2018 +0000

----------------------------------------------------------------------
 src/kudu/consensus/consensus-test-util.h   |  4 ++
 src/kudu/consensus/consensus_peers.cc      |  8 ++-
 src/kudu/consensus/consensus_peers.h       | 37 +++++++------
 src/kudu/consensus/leader_election-test.cc |  2 +-
 src/kudu/consensus/leader_election.cc      | 73 +++++++++++++++----------
 src/kudu/consensus/leader_election.h       | 11 ++--
 6 files changed, 81 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/e7ee6678/src/kudu/consensus/consensus-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus-test-util.h b/src/kudu/consensus/consensus-test-util.h
index 2d71b5c..8b6a71e 100644
--- a/src/kudu/consensus/consensus-test-util.h
+++ b/src/kudu/consensus/consensus-test-util.h
@@ -143,6 +143,10 @@ class TestPeerProxy : public PeerProxy {
 
   explicit TestPeerProxy(ThreadPool* pool) : pool_(pool) {}
 
+  std::string PeerName() const override {
+    return "TestPeerProxy";
+  }
+
  protected:
   // Register the RPC callback in order to call later.
   // We currently only support one request of each method being in flight at a time.

http://git-wip-us.apache.org/repos/asf/kudu/blob/e7ee6678/src/kudu/consensus/consensus_peers.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_peers.cc b/src/kudu/consensus/consensus_peers.cc
index dbab333..5a0c965 100644
--- a/src/kudu/consensus/consensus_peers.cc
+++ b/src/kudu/consensus/consensus_peers.cc
@@ -470,8 +470,8 @@ Peer::~Peer() {
 
 RpcPeerProxy::RpcPeerProxy(gscoped_ptr<HostPort> hostport,
                            gscoped_ptr<ConsensusServiceProxy> consensus_proxy)
-    : hostport_(std::move(hostport)),
-      consensus_proxy_(std::move(consensus_proxy)) {
+    : hostport_(std::move(DCHECK_NOTNULL(hostport))),
+      consensus_proxy_(std::move(DCHECK_NOTNULL(consensus_proxy))) {
 }
 
 void RpcPeerProxy::UpdateAsync(const ConsensusRequestPB* request,
@@ -496,7 +496,9 @@ void RpcPeerProxy::StartTabletCopy(const StartTabletCopyRequestPB* request,
   consensus_proxy_->StartTabletCopyAsync(*request, response, controller, callback);
 }
 
-RpcPeerProxy::~RpcPeerProxy() {}
+string RpcPeerProxy::PeerName() const {
+  return hostport_->ToString();
+}
 
 namespace {
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/e7ee6678/src/kudu/consensus/consensus_peers.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_peers.h b/src/kudu/consensus/consensus_peers.h
index 7d1ff74..7812687 100644
--- a/src/kudu/consensus/consensus_peers.h
+++ b/src/kudu/consensus/consensus_peers.h
@@ -27,17 +27,17 @@
 #include <glog/logging.h>
 
 #include "kudu/consensus/consensus.pb.h"
+#include "kudu/consensus/consensus.proxy.h"
 #include "kudu/consensus/metadata.pb.h"
 #include "kudu/consensus/ref_counted_replicate.h"
 #include "kudu/gutil/gscoped_ptr.h"
-#include "kudu/gutil/port.h"
 #include "kudu/rpc/response_callback.h"
 #include "kudu/rpc/rpc_controller.h"
 #include "kudu/util/locks.h"
+#include "kudu/util/net/net_util.h"
 #include "kudu/util/status.h"
 
 namespace kudu {
-class HostPort;
 class ThreadPoolToken;
 
 namespace rpc {
@@ -46,9 +46,8 @@ class PeriodicTimer;
 }
 
 namespace consensus {
-class ConsensusServiceProxy;
-class PeerProxy;
 class PeerMessageQueue;
+class PeerProxy;
 
 // A remote peer in consensus.
 //
@@ -195,6 +194,7 @@ class Peer : public std::enable_shared_from_this<Peer> {
 // be replaced for tests.
 class PeerProxy {
  public:
+  virtual ~PeerProxy() {}
 
   // Sends a request, asynchronously, to a remote peer.
   virtual void UpdateAsync(const ConsensusRequestPB* request,
@@ -216,7 +216,8 @@ class PeerProxy {
     LOG(DFATAL) << "Not implemented";
   }
 
-  virtual ~PeerProxy() {}
+  // Remote endpoint or description of the peer.
+  virtual std::string PeerName() const = 0;
 };
 
 // A peer proxy factory. Usually just obtains peers through the rpc implementation
@@ -238,22 +239,22 @@ class RpcPeerProxy : public PeerProxy {
   RpcPeerProxy(gscoped_ptr<HostPort> hostport,
                gscoped_ptr<ConsensusServiceProxy> consensus_proxy);
 
-  virtual void UpdateAsync(const ConsensusRequestPB* request,
-                           ConsensusResponsePB* response,
-                           rpc::RpcController* controller,
-                           const rpc::ResponseCallback& callback) OVERRIDE;
+  void UpdateAsync(const ConsensusRequestPB* request,
+                   ConsensusResponsePB* response,
+                   rpc::RpcController* controller,
+                   const rpc::ResponseCallback& callback) override;
 
-  virtual void RequestConsensusVoteAsync(const VoteRequestPB* request,
-                                         VoteResponsePB* response,
-                                         rpc::RpcController* controller,
-                                         const rpc::ResponseCallback& callback) OVERRIDE;
+  void RequestConsensusVoteAsync(const VoteRequestPB* request,
+                                 VoteResponsePB* response,
+                                 rpc::RpcController* controller,
+                                 const rpc::ResponseCallback& callback) override;
 
-  virtual void StartTabletCopy(const StartTabletCopyRequestPB* request,
-                                    StartTabletCopyResponsePB* response,
-                                    rpc::RpcController* controller,
-                                    const rpc::ResponseCallback& callback) OVERRIDE;
+  void StartTabletCopy(const StartTabletCopyRequestPB* request,
+                       StartTabletCopyResponsePB* response,
+                       rpc::RpcController* controller,
+                       const rpc::ResponseCallback& callback) override;
 
-  virtual ~RpcPeerProxy();
+  std::string PeerName() const override;
 
  private:
   gscoped_ptr<HostPort> hostport_;

http://git-wip-us.apache.org/repos/asf/kudu/blob/e7ee6678/src/kudu/consensus/leader_election-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/leader_election-test.cc b/src/kudu/consensus/leader_election-test.cc
index ffe72c2..f7041ab 100644
--- a/src/kudu/consensus/leader_election-test.cc
+++ b/src/kudu/consensus/leader_election-test.cc
@@ -94,7 +94,7 @@ class FromMapPeerProxyFactory : public PeerProxyFactory {
   Status NewProxy(const RaftPeerPB& peer_pb,
                   gscoped_ptr<PeerProxy>* proxy) override {
     PeerProxy* proxy_ptr = FindPtrOrNull(*proxy_map_, peer_pb.permanent_uuid());
-    if (!proxy_ptr) return Status::NotFound("No proxy for peer.");
+    if (!proxy_ptr) return Status::NotFound("no proxy for peer");
     proxy->reset(proxy_ptr);
     return Status::OK();
   }

http://git-wip-us.apache.org/repos/asf/kudu/blob/e7ee6678/src/kudu/consensus/leader_election.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/leader_election.cc b/src/kudu/consensus/leader_election.cc
index dfb38d1..0590fdf 100644
--- a/src/kudu/consensus/leader_election.cc
+++ b/src/kudu/consensus/leader_election.cc
@@ -144,6 +144,18 @@ ElectionResult::ElectionResult(VoteRequestPB vote_request, ElectionVote decision
 }
 
 ///////////////////////////////////////////////////
+// LeaderElection::VoterState
+///////////////////////////////////////////////////
+
+string LeaderElection::VoterState::PeerInfo() const {
+  std::string info = peer_uuid;
+  if (proxy) {
+    strings::SubstituteAndAppend(&info, " ($0)", proxy->PeerName());
+  }
+  return info;
+}
+
+///////////////////////////////////////////////////
 // LeaderElection
 ///////////////////////////////////////////////////
 
@@ -174,6 +186,7 @@ LeaderElection::LeaderElection(const RaftConfigPB& config,
     other_voter_uuids_.push_back(peer.permanent_uuid());
 
     gscoped_ptr<VoterState> state(new VoterState());
+    state->peer_uuid = peer.permanent_uuid();
     state->proxy_status = proxy_factory->NewProxy(peer, &state->proxy);
     InsertOrDie(&voter_state_, peer.permanent_uuid(), state.release());
   }
@@ -216,11 +229,11 @@ void LeaderElection::Run() {
     // that indicates why it failed.
     if (!state->proxy_status.ok()) {
       LOG_WITH_PREFIX(WARNING) << "Was unable to construct an RPC proxy to peer "
-                               << voter_uuid << ": " << state->proxy_status.ToString()
+                               << state->PeerInfo() << ": " << state->proxy_status.ToString()
                                << ". Counting it as a 'NO' vote.";
       {
         std::lock_guard<Lock> guard(lock_);
-        RecordVoteUnlocked(voter_uuid, VOTE_DENIED);
+        RecordVoteUnlocked(*state, VOTE_DENIED);
       }
       CheckForDecision();
       continue;
@@ -229,7 +242,7 @@ void LeaderElection::Run() {
     // Send the RPC request.
     LOG_WITH_PREFIX(INFO) << "Requesting "
                           << (request_.is_pre_election() ? "pre-" : "")
-                          << "vote from peer " << voter_uuid;
+                          << "vote from peer " << state->PeerInfo();
     state->rpc.set_timeout(timeout_);
 
     state->request = request_;
@@ -283,32 +296,36 @@ void LeaderElection::VoteResponseRpcCallback(const std::string& voter_uuid) {
 
     // Check for RPC errors.
     if (!state->rpc.status().ok()) {
-      LOG_WITH_PREFIX(WARNING) << "RPC error from VoteRequest() call to peer " << voter_uuid
-                  << ": " << state->rpc.status().ToString();
-      RecordVoteUnlocked(voter_uuid, VOTE_DENIED);
+      LOG_WITH_PREFIX(WARNING) << "RPC error from VoteRequest() call to peer "
+                               << state->PeerInfo() << ": "
+                               << state->rpc.status().ToString();
+      RecordVoteUnlocked(*state, VOTE_DENIED);
 
     // Check for tablet errors.
     } else if (state->response.has_error()) {
       LOG_WITH_PREFIX(WARNING) << "Tablet error from VoteRequest() call to peer "
-                   << voter_uuid << ": "
-                   << StatusFromPB(state->response.error().status()).ToString();
-      RecordVoteUnlocked(voter_uuid, VOTE_DENIED);
+                               << state->PeerInfo() << ": "
+                               << StatusFromPB(state->response.error().status()).ToString();
+      RecordVoteUnlocked(*state, VOTE_DENIED);
 
     // If the peer changed their IP address, we shouldn't count this vote since
     // our knowledge of the configuration is in an inconsistent state.
     } else if (PREDICT_FALSE(voter_uuid != state->response.responder_uuid())) {
-      LOG_WITH_PREFIX(DFATAL) << "Received vote response from peer we thought had UUID "
-                  << voter_uuid << ", but its actual UUID is " << state->response.responder_uuid();
-      RecordVoteUnlocked(voter_uuid, VOTE_DENIED);
+      LOG_WITH_PREFIX(DFATAL) << "Received vote response from peer "
+                              << state->PeerInfo() << ": "
+                              << "we thought peer had UUID " << voter_uuid
+                              << " but its actual UUID is "
+                              << state->response.responder_uuid();
+      RecordVoteUnlocked(*state, VOTE_DENIED);
 
     } else {
       // No error: count actual votes.
 
       highest_voter_term_ = std::max(highest_voter_term_, state->response.responder_term());
       if (state->response.vote_granted()) {
-        HandleVoteGrantedUnlocked(voter_uuid, *state);
+        HandleVoteGrantedUnlocked(*state);
       } else {
-        HandleVoteDeniedUnlocked(voter_uuid, *state);
+        HandleVoteDeniedUnlocked(*state);
       }
     }
   }
@@ -317,31 +334,31 @@ void LeaderElection::VoteResponseRpcCallback(const std::string& voter_uuid) {
   CheckForDecision();
 }
 
-void LeaderElection::RecordVoteUnlocked(const std::string& voter_uuid, ElectionVote vote) {
+void LeaderElection::RecordVoteUnlocked(const VoterState& state, ElectionVote vote) {
   DCHECK(lock_.is_locked());
 
   // Record the vote.
   bool duplicate;
-  Status s = vote_counter_->RegisterVote(voter_uuid, vote, &duplicate);
+  Status s = vote_counter_->RegisterVote(state.peer_uuid, vote, &duplicate);
   if (!s.ok()) {
-    LOG_WITH_PREFIX(WARNING) << "Error registering vote for peer " << voter_uuid
-                 << ": " << s.ToString();
+    LOG_WITH_PREFIX(WARNING) << "Error registering vote for peer "
+                             << state.PeerInfo() << ": " << s.ToString();
     return;
   }
   if (duplicate) {
     // Note: This is DFATAL because at the time of writing we do not support
     // retrying vote requests, so this should be impossible. It may be valid to
     // receive duplicate votes in the future if we implement retry.
-    LOG_WITH_PREFIX(DFATAL) << "Duplicate vote received from peer " << voter_uuid;
+    LOG_WITH_PREFIX(DFATAL) << "Duplicate vote received from peer " << state.PeerInfo();
   }
 }
 
-void LeaderElection::HandleHigherTermUnlocked(const string& voter_uuid, const VoterState& state) {
+void LeaderElection::HandleHigherTermUnlocked(const VoterState& state) {
   DCHECK(lock_.is_locked());
   DCHECK_GT(state.response.responder_term(), election_term());
 
   string msg = Substitute("Vote denied by peer $0 with higher term. Message: $1",
-                          state.response.responder_uuid(),
+                          state.PeerInfo(),
                           StatusFromPB(state.response.consensus_error().status()).ToString());
   LOG_WITH_PREFIX(WARNING) << msg;
 
@@ -352,30 +369,30 @@ void LeaderElection::HandleHigherTermUnlocked(const string& voter_uuid, const Vo
   }
 }
 
-void LeaderElection::HandleVoteGrantedUnlocked(const string& voter_uuid, const VoterState& state) {
+void LeaderElection::HandleVoteGrantedUnlocked(const VoterState& state) {
   DCHECK(lock_.is_locked());
   if (!request_.is_pre_election()) {
     DCHECK_EQ(state.response.responder_term(), election_term());
   }
   DCHECK(state.response.vote_granted());
 
-  LOG_WITH_PREFIX(INFO) << "Vote granted by peer " << voter_uuid;
-  RecordVoteUnlocked(voter_uuid, VOTE_GRANTED);
+  LOG_WITH_PREFIX(INFO) << "Vote granted by peer " << state.PeerInfo();
+  RecordVoteUnlocked(state, VOTE_GRANTED);
 }
 
-void LeaderElection::HandleVoteDeniedUnlocked(const string& voter_uuid, const VoterState& state) {
+void LeaderElection::HandleVoteDeniedUnlocked(const VoterState& state) {
   DCHECK(lock_.is_locked());
   DCHECK(!state.response.vote_granted());
 
   // If one of the voters responds with a greater term than our own, and we
   // have not yet triggered the decision callback, it cancels the election.
   if (state.response.responder_term() > election_term()) {
-    return HandleHigherTermUnlocked(voter_uuid, state);
+    return HandleHigherTermUnlocked(state);
   }
 
-  LOG_WITH_PREFIX(INFO) << "Vote denied by peer " << voter_uuid << ". Message: "
+  LOG_WITH_PREFIX(INFO) << "Vote denied by peer " << state.PeerInfo() << ". Message: "
             << StatusFromPB(state.response.consensus_error().status()).ToString();
-  RecordVoteUnlocked(voter_uuid, VOTE_DENIED);
+  RecordVoteUnlocked(state, VOTE_DENIED);
 }
 
 std::string LeaderElection::LogPrefix() const {

http://git-wip-us.apache.org/repos/asf/kudu/blob/e7ee6678/src/kudu/consensus/leader_election.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/leader_election.h b/src/kudu/consensus/leader_election.h
index 33e4241..f33c268 100644
--- a/src/kudu/consensus/leader_election.h
+++ b/src/kudu/consensus/leader_election.h
@@ -156,6 +156,7 @@ class LeaderElection : public RefCountedThreadSafe<LeaderElection> {
   friend class RefCountedThreadSafe<LeaderElection>;
 
   struct VoterState {
+    std::string peer_uuid;
     gscoped_ptr<PeerProxy> proxy;
 
     // If constructing the proxy failed (e.g. due to a DNS resolution issue)
@@ -165,6 +166,8 @@ class LeaderElection : public RefCountedThreadSafe<LeaderElection> {
     rpc::RpcController rpc;
     VoteRequestPB request;
     VoteResponsePB response;
+
+    std::string PeerInfo() const;
   };
 
   typedef std::unordered_map<std::string, VoterState*> VoterStateMap;
@@ -181,16 +184,16 @@ class LeaderElection : public RefCountedThreadSafe<LeaderElection> {
   void VoteResponseRpcCallback(const std::string& voter_uuid);
 
   // Record vote from specified peer.
-  void RecordVoteUnlocked(const std::string& voter_uuid, ElectionVote vote);
+  void RecordVoteUnlocked(const VoterState& state, ElectionVote vote);
 
   // Handle a peer that reponded with a term greater than the election term.
-  void HandleHigherTermUnlocked(const std::string& voter_uuid, const VoterState& state);
+  void HandleHigherTermUnlocked(const VoterState& state);
 
   // Log and record a granted vote.
-  void HandleVoteGrantedUnlocked(const std::string& voter_uuid, const VoterState& state);
+  void HandleVoteGrantedUnlocked(const VoterState& state);
 
   // Log the reason for a denied vote and record it.
-  void HandleVoteDeniedUnlocked(const std::string& voter_uuid, const VoterState& state);
+  void HandleVoteDeniedUnlocked(const VoterState& state);
 
   // Returns a string to be prefixed to all log entries.
   // This method accesses const members and is thread safe.