I am learning master-slave model in zookeeper. I just have a question:
What would happen if one master and one slave can't communicate to each other? like master can't get ACK from slave ? Would slave reboot itself?
That depends one how the quorum gets partitioned. You may know that zookeeper operates as a quorum of zookeeper servers. If two servers cannot talk to each other, that means there is a network partitioning problem (one set of servers cannot reach the other servers in different parts of a network). Since we use odd number of servers in the quorum, there will be two partitions, one with majority of servers and one with a minority.
If leader is in the majority partition,
quorum will continue to operate as the leader has the majority of the quorum. In the minority partition, servers will shutdown and go to a leader election phase. Following text is quoted from a mail thread in user mail list
of Apache Zookeeper.
After the partition, all the servers in the minority region will get shutdown and moves to leader election phase. All the client sessions connected to these servers will be disconnected and will receive "KeeperState.Disconnected" event to their watchers, if any registered.
But ZooKeeper supports read-only server mode. In this mode, client can connect to the read-only server even when the server might be partitioned from the quorum.
If the leader is in the minority partition,
Again, a leader election will happen in both partitions and minority partition won't be able to elect a leader. Therefore, will shutdown. Majority partition will elect a new leader and continue operation.
In your question, what you refer as master cannot connect to slave
is an example to network partitioning. Either the master (leader) is in the minority partition or the slave is in the minority partition.
Hope you got the idea :-)