zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1481325 - in /zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java
Date Sat, 11 May 2013 13:35:14 GMT
Author: fpj
Date: Sat May 11 13:35:13 2013
New Revision: 1481325

URL: http://svn.apache.org/r1481325
Log:
ZOOKEEPER-1697. large snapshots can cause continuous quorum failure
  (phunt via fpj)


Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1481325&r1=1481324&r2=1481325&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Sat May 11 13:35:13 2013
@@ -345,6 +345,9 @@ BUGFIXES:
   ZOOKEEPER-1700. FLETest consistently failing - setLastSeenQuorumVerifier
   seems to be hanging (phunt via fpj)
 
+  ZOOKEEPER-1697. large snapshots can cause continuous quorum failure
+  (phunt via fpj)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java?rev=1481325&r1=1481324&r2=1481325&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java Sat
May 11 13:35:13 2013
@@ -64,8 +64,12 @@ public class LearnerHandler extends Thre
 
     final Leader leader;
 
-    long tickOfLastAck;
-
+    /** Deadline for receiving the next ack. If we are bootstrapping then
+     * it's based on the initLimit, if we are done bootstrapping it's based
+     * on the syncLimit. Once the deadline is past this learner should
+     * be considered no longer "sync'd" with the leader. */
+    volatile long tickOfNextAckDeadline;
+    
     /**
      * ZooKeeper server identifier of this learner
      */
@@ -104,7 +108,7 @@ public class LearnerHandler extends Thre
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("LearnerHandler ").append(sock);
-        sb.append(" tickOfLastAck:").append(tickOfLastAck());
+        sb.append(" tickOfNextAckDeadline:").append(tickOfNextAckDeadline());
         sb.append(" synced?:").append(synced());
         sb.append(" queuedPacketLength:").append(queuedPackets.size());
         return sb.toString();
@@ -233,6 +237,9 @@ public class LearnerHandler extends Thre
     @Override
     public void run() {
         try {
+            tickOfNextAckDeadline = leader.self.tick
+                    + leader.self.initLimit + leader.self.syncLimit;
+
             ia = BinaryInputArchive.getArchive(new BufferedInputStream(sock
                     .getInputStream()));
             bufferedOutput = new BufferedOutputStream(sock.getOutputStream());
@@ -468,7 +475,7 @@ public class LearnerHandler extends Thre
                 LOG.error("Next packet was supposed to be an ACK");
                 return;
             }
-            LOG.debug("Received NEWLEADER-ACK message from " + sid);   
+            LOG.info("Received NEWLEADER-ACK message from " + sid);
             leader.processAck(this.sid, qp.getZxid(), sock.getLocalSocketAddress());
             
             // now that the ack has been processed expect the syncLimit
@@ -500,7 +507,7 @@ public class LearnerHandler extends Thre
                 if (LOG.isTraceEnabled()) {
                     ZooTrace.logQuorumPacket(LOG, traceMask, 'i', qp);
                 }
-                tickOfLastAck = leader.self.tick;
+                tickOfNextAckDeadline = leader.self.tick + leader.self.syncLimit;
 
 
                 ByteBuffer bb;
@@ -615,8 +622,8 @@ public class LearnerHandler extends Thre
         leader.removeLearnerHandler(this);
     }
 
-    public long tickOfLastAck() {
-        return tickOfLastAck;
+    public long tickOfNextAckDeadline() {
+        return tickOfNextAckDeadline;
     }
 
     /**
@@ -638,6 +645,6 @@ public class LearnerHandler extends Thre
 
     public boolean synced() {
         return isAlive()
-        && tickOfLastAck >= leader.self.tick - leader.self.syncLimit;
+        && leader.self.tick <= tickOfNextAckDeadline;
     }
 }

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java?rev=1481325&r1=1481324&r2=1481325&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java Sat May
11 13:35:13 2013
@@ -406,7 +406,7 @@ public class QuorumPeer extends Thread i
     /**
      * The current tick
      */
-    protected int tick;
+    protected volatile int tick;
 
     /**
      * @deprecated As of release 3.4.0, this class has been deprecated, since



Mime
View raw message