Hi Paul, On 7 July 2016 at 14:05, Paul K. Harter, Jr. <[email protected]> wrote:
> Camillle, thanks for your response! If I could burrow a little deeper: > > > > I had seen about read-only clients, who can tolerate arbitrarily stale > data and that servers can respond to them when they are isolated from the > quorum. I was actually wondered about an intermediate case, where, e.g. > the leader crashes and a server who is still connected to the other servers > initiates leader election. Question: > > > > These servers can’t do updates until they’ve settled on a new leader, but > can they accept connections or continue to respond to reads, based on their > current data?? > Participants (servers that can be either a follower or a leader) will accept connections whilst in LOOKING mode, but immediately close them. Confront with: When the follower gets disconnected from the leader this happens: https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java#L1115 and the call to Learner.shutdown() happens: https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/server/quorum/Learner.java#L616 which means that new connections will be established, but immediately rejected: https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java#L429 > > You said that a follower who loses quorum (can no longer see the majority > of servers) drops connections to clients so they know to start trying to > reconnect (perhaps except for read-only clients, which we can ignore for > the moment). Question: > > > > It would seem to make sense that a follower who just loses contact with > the leader DOES NOT drop clients during leader election because and leader > election is usually successful and short enough that it would be too > disruptive. Is this true?? > > I wish it were, but it isn't. If it was, it would reduce the pressure on participants that need to deal with closing & recreating all the client sockets when the leader goes away and an election is called. But it would also make the state machine referenced above much more complicated. About read-only clients, you might be interested in: https://issues.apache.org/jira/browse/ZOOKEEPER-1607 which we use in production at Pinterest. -rgs
