openmessaging / dledger

A raft-based java library for building high-available, high-durable, strong-consistent commitlog.
Apache License 2.0
801 stars 315 forks source link

Support fast advance commit index by appending no-op entry #305

Closed TheR1sing3un closed 1 year ago

TheR1sing3un commented 1 year ago

According to raft paper, leader can only commit the entries which are belong to current term. So in a sceniaro: leader n0 has appended entry-1 to n1 and n2, but before n0 commit the index-1, it has crashed. Now n1 became leader, but it can't commit the index-1 although more than half peers have stored the entry-1, and the index-1 will never be commited util a new entry is sent to leader for appending. So we can let new leader append a no-op entry as soon as it becomes leader.When this no-op entry is replicated to more than half peers, leader will advance the commit index to this no-op entry's index.