-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log repair #4
Log repair #4
Conversation
…e logged it This saves having to truncate leader logs on failed attempt to handle client cmds. I think this is consistent with the raft spec, which is vague on the ordering here. Also started to handle the "rejection scenario" where the AEReq is actively rejected by a peer because it's log is out of date, but long ways still to go on log repair. Cosmetic/comment changes to log.rs and peer.rs
This is to properly determining when a (majority-1) of peers have logged the cmd in question. log repair still not (fully) implemented. Also refactored leader_loop a slight bit - pulled out some code to other helper methods.
This would be for cases where another peer claims to be implemented. This case is NOT yet handled at all in the code. Just putting a placeholder for where the logic goes.
Event Sender/Receiver now being passed into server_loop and submethods. Added select at top of leader_loop to choose between event receiver and AEResponse receiver. Passes existing tests. Need to refactor/clean up and then add more/better tests. Log repair/catch up not yet implemented, but placeholder section exists in the code.
refactoring only commit
Created ldr_process_cmd_from_client, pulling code out of leader_loop. process_aeresponse_from_peer now used in two places to make code more DRY
Also changed Makefile to have all: server as first target to match pull request.
wrt 2, sec. 5.3 Raft spec says:
So it seems like the right behavior - "majority of servers" and all. I question why you chose I read over the rest of the changes, and barring the fact that we seem to have added more 👍 from me. |
That is correct, the leader logs it as soon as The Raft spec states:
Because we haven't yet defined the StateMachine to be anything other than the commit_idx, in order to stay consisent with the "Leader Append-Only" rule (p. 5 Raft spec), I had to change the order specified above. Only after
The only unsafe code is for the Select handling, which is required for reasons I'm not clear about. Usually this is hidden inside the select! macro (which uses these unsafe blocks), but the select! macro has two flaws that makes it hard to use in all circumstances:
|
Oh,
|
I now have the leader_loop refactored sufficiently that I'm reading to start the log repair back and forth conversation between leader and follower.
A few important changes so far:
majority-1
peers have already logged it; I think this is still consistent with the Raft spec and allows avoiding having the leader truncate its logs. Since one of the rules is "the leader only ever appends" to its log, this looks correct to me.This is the prelude for starting on the log repair conversation that happens between follower and leader, which will be done next.
Change of Server struct
I hit an ownership/borrow problem with the "c" and "p" Event Sender and Receiver channels embedded in the Server struct. In this branch I have pulled them out.
Now I create the Sender/Receiver channel pair in the
run
method and pass the Receiver into theserve_loop
method:and then pass it into the serve_loop submethods that need it (so far)
Let me know if this will conflict with any changes you are making. This model also allows us to use the
select!
macro rather than having to manually code with the Select impl.