1. 21 Mar, 2022 1 commit
  2. 13 Mar, 2022 3 commits
  3. 06 Mar, 2022 1 commit
  4. 07 Feb, 2022 1 commit
  5. 16 Nov, 2021 1 commit
    • Yossi Gottlieb's avatar
      Properly get coverage from all tests. (#70) · ada3d6a0
      Yossi Gottlieb authored
      * Add COVERAGE=1 Makefile option to build libraft with coverage.
      * Refactor CFFI module to use the existing shared object in an
        out-of-line configuration, so there's no need to build and re-build
        it.
      * Makefile adjustments to build the module CFFI as needed.
      * Remove raft_get_snapshot_entry_idx, a prototype for an undefined
        function that breaks CFFI.
      * Add a gcov Makefile target to fetch both unit tests and integration
        test coverage in one shot.
      ada3d6a0
  6. 15 Nov, 2021 1 commit
  7. 07 Oct, 2021 1 commit
    • Shaya Potter's avatar
      redo/tweak transfer leader in libraft (#61) · 63b0b1c1
      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
  8. 23 Sep, 2021 2 commits
    • Shaya Potter's avatar
      Adding support for TimeoutNow RPC (#7) · 575335c3
      Shaya Potter authored
      this is the small modifications needed for raftlib to support timeout now rpc
      
      1) add a flag to requestvote type to tell other nodes its overriding normal chec
      2) new send_timeoutnow callback to send a timeout now rpc at right time
      3) call said callback is we've marked the node as timeout now and in raft_appendentries_response raft_get_current_idx(me_) == r->current_idx (i.e. response says the node's idx is up to date with leader)
      4) add helper functions to set/get/reset timeout flag on node structs for targeted node.
      
      how it would be used by client
      
      1) client of libraft will call raft_transfer_leader(raft_server_t* me_, raft_node_id_t node_id) to target the node they want to transfer to.
      
      2) client of libraft will provide the send_timeoutnow() callback for the actual sending of the rpc
      
      3) client of libraft will modify their existing notify_state_event() callback to observe the result of the timeout now operation.
      
      if it receives a RAFT_STATE_LEADERSHIP_TRANSFER_FAILED, then the transfer failed
      
      if it received a RAFT_STATE_FOLLOWER, then it inspects for the actual leader to see if its the expected one and can return that it was transferred to expected node or not
      
      if it received a RAFT_STATE_CANDIDATE, then the transfer also failed, as the targeted node sent a request vote which removed leadership, but wasn't able to win the election.
      
      With PreVote, this latter case should be very rare.
      575335c3
    • Ozan Tezcan's avatar
      Define separate callback function for node id retrieval (#55) · ce8b0f02
      Ozan Tezcan authored
      Define separate callback function for node id retrieval
      ce8b0f02
  9. 15 Sep, 2021 1 commit
  10. 14 Sep, 2021 1 commit
  11. 12 Sep, 2021 1 commit
    • Shaya Potter's avatar
      add a read_queue test to virtraft (#41) · bdd0797f
      Shaya Potter authored
      * add a read_queue test to virtraft
      
      every iteration we push a read_queue request and the handler and an we pass to it set a variable on calling.  we can use this to make sure that the read_queue doesn't get too far from the iteration.  i.e. we pass the leader's msg_id and can check to ensure that leader's msg_id doesn't get too far from the msg_id (variable) we see in read_queue test
      
      this is analog to the current log applying deadlock test.
      
      * implements msg_id checking in virtraft for verification of read_queue requests
      
      When we pop an entry off the read_queue with the can_read flag, we verify across all nodes that the majority of nodes have accepted from the leader a msg_id past what this read_queue entry needs.
      
      the problem with this is, that until now, msg_id was private to each server instance and has no relevance to the followre nodes except to include it back in response. 
      
      we change that to have the followers store the max msg_id they've seen from their current leader
      
      using that, in the read_queue_handler we can verify that the leader's voting nodes have a quorum past the msg_id variable that the handler will return to ensure that this read_queue handler call is correct.
      bdd0797f
  12. 09 Sep, 2021 1 commit
  13. 01 Sep, 2021 1 commit
    • Shaya Potter's avatar
      include the prev_log_idx in the appendentry response (#45) · 64747dee
      Shaya Potter authored
      the problem we have is that 2 appendentries can be in process in parallel
      
      Howver, the response handler doesn't expect this, it will reset the next_idx in both, but currently resets next_idx based on next_idx's value, not the old value that was the basis of prev_log_idx.
      
      Solution: return prev_log_idx in the response
      
      Problem with solution: prev_log_idx is not always based on next_idx from node, but can be based on a snapshot idx if it no longer exists. I haven't coded this yet, but perhaps can determine if the prev_log_idx that is returned is the snapshot_idx and if so, then dont increment by 1. Its possible we could pass even another flag into the appendentries struct to say if its a snapshot, but that's ugly.
      
      In addition, we increment msg_id on each appendentries so that if a response comes back out of order and we have already accepted the later response, we just ignore this response.
      
      In addition, on appendentry response, even if the appendentry wasn't a success, as long as its the same term as us (i.e. we are still the leader) then for leader/quorum purposes, that is sufficient, so move up set_last_ack to right after term test.
      64747dee
  14. 19 Aug, 2021 1 commit
  15. 30 Jul, 2021 1 commit
    • Shaya Potter's avatar
      remove REMOVE_NODE log type and include its semantics in DEMOTE (#25) · d4d15e04
      Shaya Potter authored
      this commit changes libraft's from using the DEMOTE_NODE log entry which would then initiate a REMOVE_NODE log entry on the DEMOTE's commit, to only using a REMOVE.  
      
      * add the removal of the active node flag on append of REMOVE and (add back if reverted)
      * modify is_voting to check for active state as well
      
      this enables simplifying appending and reverting nodes, as we shouldn't be touching voting state, (as a removing node might not be voting yet), only its active state.  and as the is_voting check also now checks for active state, simplifies a lot of code that manually tested both.
      
      * add a test for reversion of a non voting node removal
      
      previously, the code could not handle demoting/removing a non voting node, as demote would want to unset the voting flag (which a non voting node obviously doesn't have), and would therefore fail an assertion.
      
      with the new code, we no longer unset the voting flag in removal, and this test make sure both the is_voting and is_active return as expected through a process of add/removal/revert
      d4d15e04
  16. 16 Apr, 2020 1 commit
  17. 12 Mar, 2020 1 commit
    • Yossi Gottlieb's avatar
      Add RAFT_LOGTYPE_NO_OP. · 5d7915f3
      Yossi Gottlieb authored
      The no-op entry gets committed as soon as a new leader is elected, in
      order to establish the commit index and prevent stale reads.
      5d7915f3
  18. 31 Dec, 2018 1 commit
  19. 19 Dec, 2018 2 commits
  20. 18 Dec, 2018 1 commit
  21. 13 Dec, 2018 1 commit
  22. 09 Dec, 2018 1 commit
  23. 06 Dec, 2018 1 commit
  24. 16 Oct, 2018 1 commit
    • Yossi Gottlieb's avatar
      Fix a memory leak with log_clear. · 89d793a0
      Yossi Gottlieb authored
      This is probably most common when loading a snapshot.  Currently it is
      only possibly to free allocated entry memory on log_pop and log_poll,
      but neither are called on log_reset().
      
      This is a quick and non-breaking fix.  A better but not backward
      compatible option can be to have a free function callback as part of
      the entry itself (automatically called when needed, not by log_pop or
      log_poll).  This would also make it easier to avoid redundant buffer
      allocs/copies on the app side.
      89d793a0
  25. 07 Aug, 2018 2 commits
  26. 30 Jul, 2018 2 commits
    • Yossi Gottlieb's avatar
      Add raft_cancel_snapshot(). · 074091c1
      Yossi Gottlieb authored
      This cancels the snapshot operation and reverts back to the state we
      were in before raft_begin_snapshot().
      
      It is useful for cases where the snapshot operation fails.  It is the
      caller's responsibility to make sure the FSM state remains intact of
      course.
      074091c1
    • Yossi Gottlieb's avatar
      Add raft_cancel_snapshot(). · 3badd2a0
      Yossi Gottlieb authored
      This cancels the snapshot operation and reverts back to the state we
      were in before raft_begin_snapshot().
      
      It is useful for cases where the snapshot operation fails.  It is the
      caller's responsibility to make sure the FSM state remains intact of
      course.
      3badd2a0
  27. 12 Jul, 2018 2 commits
  28. 10 Jul, 2018 1 commit
    • Yossi Gottlieb's avatar
      Add raft_pop_entry(). · 876f8d7c
      Yossi Gottlieb authored
      This is required to allow append-only persistent log formats, where
      raft_append_entry() is called but may be reverted later on.
      876f8d7c
  29. 20 Jun, 2018 2 commits
  30. 11 Jun, 2018 3 commits