zookeeper 写入失败处理
zookeeper write failure handling
我有一个关于 zookeeper 如何处理写入失败的问题。让我们假设,有 3 个节点,写入在 1 上成功但在 2 上失败,我知道 zookeeper 会 return 错误。但是在一个节点上成功写入会发生什么?是回滚还是保留更改并期望最终 复制到其他节点?
Zookeeper 使用原子消息系统。以下 article:
对此进行了很好的解释
ZooKeeper uses a variation of two-phase-commit protocol for replicating transactions to followers. When a leader receive a change update from a client it generate a transaction with sequel number c and the leader’s epoch e and send the transaction to all followers. A follower adds the transaction to its history queue and send ACK to the leader. When a leader receives ACK’s from a quorum it send the the quorum COMMIT for that transaction. A follower that accept COMMIT will commit this transaction unless c is higher than any sequence number in its history queue. It will wait for receiving COMMIT’s for all its earlier transactions (outstanding transactions) before commiting.
另外 official documentation 也很有用。
我有一个关于 zookeeper 如何处理写入失败的问题。让我们假设,有 3 个节点,写入在 1 上成功但在 2 上失败,我知道 zookeeper 会 return 错误。但是在一个节点上成功写入会发生什么?是回滚还是保留更改并期望最终 复制到其他节点?
Zookeeper 使用原子消息系统。以下 article:
对此进行了很好的解释ZooKeeper uses a variation of two-phase-commit protocol for replicating transactions to followers. When a leader receive a change update from a client it generate a transaction with sequel number c and the leader’s epoch e and send the transaction to all followers. A follower adds the transaction to its history queue and send ACK to the leader. When a leader receives ACK’s from a quorum it send the the quorum COMMIT for that transaction. A follower that accept COMMIT will commit this transaction unless c is higher than any sequence number in its history queue. It will wait for receiving COMMIT’s for all its earlier transactions (outstanding transactions) before commiting.
另外 official documentation 也很有用。