12.0 Zookeeper Data Synchronization Process
Category Zookeeper Tutorial
In Zookeeper, the ZAB protocol is primarily relied upon to achieve distributed data consistency.
The ZAB protocol is divided into two parts:
Message Broadcasting
Crash Recovery
Message Broadcasting
Zookeeper uses a single master process, the Leader, to receive and process all client transaction requests, and employs the atomic broadcast protocol of the ZAB protocol to broadcast transaction requests as Proposal proposals to all Follower nodes. When more than half of the Follower servers in the cluster provide correct ACK feedback, the Leader will then send commit messages to all Follower servers again to commit the proposal. This process can be briefly referred to as the 2PC transaction commit. The entire process can be referred to the following diagram, note that the Observer node is only responsible for synchronizing the Leader's data and does not participate in the 2PC data synchronization process.
Crash Recovery
The message broadcasting works well under normal circumstances, but once the Leader server crashes, or due to network reasons, the Leader server loses communication with more than half of the Followers, it will enter the crash recovery mode and a new Leader server needs to be elected. There may be two potential data inconsistencies during this process, which need to be avoided by the characteristics of the ZAB protocol.
- The Leader server sends out the commit message and then crashes immediately.
- The Leader server proposes a proposal and then crashes immediately.
The ZAB protocol's recovery mode uses the following strategies:
- Elect the node with the largest zxid as the new leader.
- The new leader processes the messages in the transaction log that have not yet been committed.
The next chapter will detail the leader election process.
-2.0 Zookeeper Installation Configuration
-3.0 Zookeeper Linux Server Cluster Setup Steps
-4.0 Zookeeper Java Client Setup
-5.0 Detailed Explanation of Zookeeper Data Model znode Structure
-6.0 Basic Principles of Zookeeper Session
-7.0 Basic Commands of Zookeeper Client
-8.0 Zookeeper Four-Word Commands
-10.0 Zookeeper Access Control ACL
-11.0 Analysis of the Principle of Zookeeper Watcher Event Mechanism
- 12.0 Zookeeper Data Synchronization Process
-13.0 Principle of Zookeeper Leader Election
-14.0 Principle of Implementing Distributed Locks in Zookeeper