|
@@ -308,7 +308,7 @@ public class Leader {
|
|
cnxAcceptor.setName("LearnerCnxAcceptor-" + ss.getLocalSocketAddress());
|
|
cnxAcceptor.setName("LearnerCnxAcceptor-" + ss.getLocalSocketAddress());
|
|
cnxAcceptor.start();
|
|
cnxAcceptor.start();
|
|
|
|
|
|
- long epoch = getEpochToPropose(self.getId(), self.getAcceptedEpoch());
|
|
|
|
|
|
+ long epoch = getEpochToPropose(self.getId(), self.getAcceptedEpoch());
|
|
|
|
|
|
zk.setZxid(ZxidUtils.makeZxid(epoch, 0));
|
|
zk.setZxid(ZxidUtils.makeZxid(epoch, 0));
|
|
|
|
|
|
@@ -377,15 +377,15 @@ public class Leader {
|
|
if (!tickSkip) {
|
|
if (!tickSkip) {
|
|
self.tick++;
|
|
self.tick++;
|
|
}
|
|
}
|
|
- int syncedCount = 0;
|
|
|
|
HashSet<Long> syncedSet = new HashSet<Long>();
|
|
HashSet<Long> syncedSet = new HashSet<Long>();
|
|
|
|
|
|
// lock on the followers when we use it.
|
|
// lock on the followers when we use it.
|
|
syncedSet.add(self.getId());
|
|
syncedSet.add(self.getId());
|
|
synchronized (learners) {
|
|
synchronized (learners) {
|
|
for (LearnerHandler f : learners) {
|
|
for (LearnerHandler f : learners) {
|
|
- if (f.synced()) {
|
|
|
|
- syncedCount++;
|
|
|
|
|
|
+ // Synced set is used to check we have a supporting quorum, so only
|
|
|
|
+ // PARTICIPANT, not OBSERVER, learners should be used
|
|
|
|
+ if (f.synced() && f.getLearnerType() == LearnerType.PARTICIPANT) {
|
|
syncedSet.add(f.getSid());
|
|
syncedSet.add(f.getSid());
|
|
}
|
|
}
|
|
f.ping();
|
|
f.ping();
|
|
@@ -395,7 +395,7 @@ public class Leader {
|
|
//if (!tickSkip && syncedCount < self.quorumPeers.size() / 2) {
|
|
//if (!tickSkip && syncedCount < self.quorumPeers.size() / 2) {
|
|
// Lost quorum, shutdown
|
|
// Lost quorum, shutdown
|
|
// TODO: message is wrong unless majority quorums used
|
|
// TODO: message is wrong unless majority quorums used
|
|
- shutdown("Only " + syncedCount + " followers, need "
|
|
|
|
|
|
+ shutdown("Only " + syncedSet.size() + " followers, need "
|
|
+ (self.getVotingView().size() / 2));
|
|
+ (self.getVotingView().size() / 2));
|
|
// make sure the order is the same!
|
|
// make sure the order is the same!
|
|
// the leader goes to looking
|
|
// the leader goes to looking
|
|
@@ -770,7 +770,7 @@ public class Leader {
|
|
}
|
|
}
|
|
connectingFollowers.add(sid);
|
|
connectingFollowers.add(sid);
|
|
QuorumVerifier verifier = self.getQuorumVerifier();
|
|
QuorumVerifier verifier = self.getQuorumVerifier();
|
|
- if (connectingFollowers.contains(self.getId()) &&
|
|
|
|
|
|
+ if (connectingFollowers.contains(self.getId()) &&
|
|
verifier.containsQuorum(connectingFollowers)) {
|
|
verifier.containsQuorum(connectingFollowers)) {
|
|
waitingForNewEpoch = false;
|
|
waitingForNewEpoch = false;
|
|
self.setAcceptedEpoch(epoch);
|
|
self.setAcceptedEpoch(epoch);
|