eBay / NuRaft

C++ implementation of Raft core logic as a replication library
Apache License 2.0
1.02k stars 240 forks source link

Preconditions of apply_pack #455

Closed unixod closed 4 weeks ago

unixod commented 1 year ago

Hi,

Could you help to clarify preconditions which apply_pack may rely on? In particular I'm wondering which of cases listed below are possible.

(In the list below by index I refer to first parameter of apply_pack)

  1. _index < log_store::startindex()
  2. _index > log_store::nextslot()
  3. _index + number_of_logs(pack) < log_store::nextslot()

If 3rd case is possible then may we truncate log entries which go after index + number_of_logs(pack) as part of apply_pack execution?

greensky00 commented 1 year ago

pack is invoked in leader's side when below conditions are met. Let's say S1 is leader (pack) and S2 is follower (apply_pack).

Then apply_pack's first parameter (index you referred to) will always be S2's next_slot(). Leader always sends the log starting from next_slot() of the follower, so none of three can be possible, unless follower's log store is changed before receiving the pack message from the leader.

unixod commented 4 weeks ago

Thanks!