Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor: revision generation #491

Closed
bsbds opened this issue Oct 20, 2023 · 1 comment
Closed

Refactor: revision generation #491

bsbds opened this issue Oct 20, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bsbds
Copy link
Collaborator

bsbds commented Oct 20, 2023

Why

In #254 we added a prepare stage in the command executor to assign each command with a revision. However, in current logic the prepare method is called inside the conflict_checked_mpmc, this present the following behaviour:

  • the commands is executed in the conflict order
  • the leader may call send_sp_exe on a command and the follower always calls send_after_sync

These may result in revision is assigned in different order between leader and followers.

Refactor

I plan to move the calls of prepare to raw_curp. As soon as a server gets a new valid log, it assign a prepare result to it.

This include the following changes:

  • move command executor from conflict_checked_mpmc to raw_curp
  • add a prepare_board to raw_curp context to temporarily store the prepare result
  • On the leader calls prepare in handle_propose
  • On the follower calls prepare in handle_append_entries
  • In apply, before the call of send_after_sync, remove the prepare result and send it to the conflict_checked_mpmc.

This guarantees the revisions is assigned in the order of log index and consistency among servers.

@bsbds
Copy link
Collaborator Author

bsbds commented Oct 20, 2023

In handle_propose the leader need to generate the prepare result(revision) for the execution stage(beacuse the revision need to return to user in speculative execute), but this prepare result may get reverted if the leadership changes. So the command executor need to introdue another method called prepare_commit. This method is called after the leader knows that the log is commited.

After this change, the prepare stage should not increment the revision generator, but pre-assign a revsion(use another counter to store this), and the revision is actually incremented after prepare_commit is called. If the leader steps down, it need to clear the pre-assign counter.

@Phoenix500526 Phoenix500526 added the Improvement Refactor or optimization, including process, performance or something like that label Nov 22, 2023
@bsbds bsbds added this to the v0.7.0 milestone Nov 22, 2023
@bsbds bsbds added bug Something isn't working and removed Improvement Refactor or optimization, including process, performance or something like that labels Nov 22, 2023
@bsbds bsbds closed this as completed Aug 27, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants