Github user mkedwards commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/707#discussion_r235808196
  
    --- Diff: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeer.java
 ---
    @@ -108,7 +109,11 @@
         LocalPeerBean jmxLocalPeerBean;
         private Map<Long, RemotePeerBean> jmxRemotePeerBean;
         LeaderElectionBean jmxLeaderElectionBean;
    -    private QuorumCnxManager qcm;
    +
    +    // The QuorumCnxManager is held through an AtomicReference to ensure 
cross-thread visibility
    +    // of updates; see the implementation comment at 
setLastSeenQuorumVerifier().
    +    private AtomicReference<QuorumCnxManager> qcmRef = new 
AtomicReference<>();
    --- End diff --
    
    I am hoping to reduce the need for synchronized blocks in follow-up 
changes.  For now, I added a simple use of getAndSet() to detect multiple calls 
to createElectionAlgorithm() and ensure that the QCM that's being dropped on 
the floor gets halted first.


---

Reply via email to