-
Shaya Potter authored
this started off as a small tweak and grew a bit 1) new callback for transfer leader result, along with its own enum of states 2) change/remove raft_reset_transfer_leader() calls only call in places where there's a new leader or timeout (i.e. failed to transfer within period). so, we only reset in 3 places 1) recv_appendentries 2) raft_periodic (timeout) 3) raft_become_leader 2a) raft_become_leader also got refactored a little to only issue the normal cb.notify_state_event() callback after it has set its state to be leader (as before, it could fail after the callback was issued) 2b) in raft_periodic the raft_reset_transfer_leader() is pulled out the "if LEADER" block, as will lose leader when a vote is issued to it, we still want it to timeout if leadership isn't gained 3) raft_reset_transfer_leader() does the logic for determining success/failure now, but becaue timeout is its own result which can't be determined by just looking at leader/desired, add a new flag to it to note timeout state 4) leader stickiness in requestvote is only tested for prevote (as in a timeout now case, we want to drop the timeout now flag after prevotes are sent). The idea is that we will only get to actual election if prevote passes. 4) a bunch of new tests * fix issue with timeout flag to reset_transfer_leader also fix test to catch the original error * libraft/redisraft changes needed for e2e leader transfer * make leader stickiness only for prevote
63b0b1c1