If we are leader and store two entries, the first having quorum and being committed/applied and the second not having quorum. A new leader should be able to truncate the second entry.
That was not possible before as the n.loadEntry(ae.pindex) and n.truncateWAL(eae.pterm, eae.pindex) combination would remove two entries, not just one.
We now check if the entry stored at ae.pindex has a matching term with ae.pterm, if so we can truncate entries past that point and then simply continue storing that append entry. Instead of needing to truncate, stop, get a heartbeat, start catchup, get the same append entry again, store it, get the next entry, stop catchup, etc. In this case we can now just, truncate and store.
If we are leader and store two entries, the first having quorum and being committed/applied and the second not having quorum. A new leader should be able to truncate the second entry.
That was not possible before as the
n.loadEntry(ae.pindex)
andn.truncateWAL(eae.pterm, eae.pindex)
combination would remove two entries, not just one.We now check if the entry stored at
ae.pindex
has a matching term withae.pterm
, if so we can truncate entries past that point and then simply continue storing that append entry. Instead of needing to truncate, stop, get a heartbeat, start catchup, get the same append entry again, store it, get the next entry, stop catchup, etc. In this case we can now just, truncate and store.Signed-off-by: Maurice van Veen github@mauricevanveen.com