zk1931 / jzab

ZooKeeper Atomic Broadcast in Java
http://zk1931.github.io/jzab/master/
Apache License 2.0
54 stars 23 forks source link

ack processor doesn't need to send commit for already committed transactions #85

Closed ghost closed 10 years ago

ghost commented 10 years ago

Currently AckProcessor sends out a commit message after each ack, even if the acknowledged transaction has already been committed. Instead, it should keep track of the last committed zxid and ignore ack if the acknowledged zxid is smaller than or equal to the last committed zxid.

=== edit: typo

EasonLiao commented 10 years ago

The leader sends duplicate COMMIT messages because of the newly joined followers.

Image there are two servers form a quorum, they have last acked zxid like :

S1 : <0,5>
S2: <0, 5>

Then I sent the COMMIT(0, 5) to the two. Then a new follower joins and ACK(0,3) :

S1 : <0,5>
S2: <0, 5>
S3: <0, 3>

We still decide the COMMIT is (0, 5) but because we've already sent the COMMIT(0,5) we won't send it anymore. In this case the new joined follower never get the chance to deliver the committed transactions.

EasonLiao commented 10 years ago

Another solution is that we keep the last committed zxid for each follower. Yeah, that would be a way to solve this.