Skip to content
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

raft: support lazy replication #131588

Merged
merged 4 commits into from
Oct 2, 2024
Merged

Conversation

pav-kv
Copy link
Collaborator

@pav-kv pav-kv commented Sep 30, 2024

This PR adds support for LazyReplication mode in raft. In this mode, the leader does not send MsgApp messages eagerly to StateReplicate peers. Instead, the appends are requested explicitly by the application layer, via the RawNode.SendMsgApp() method.

The application:

  • monitors the replication flow state to all followers, e.g. using the RawNode.Status() method,
  • for peers who have outstanding replication work, decides when and how much worth of the log to send out,
  • fetches the log slices from the RawNode.LogSnapshot(),
  • sends the appends using the RawNode.SendMsgApp() method.

Part of #128779

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@pav-kv pav-kv force-pushed the raft-lazy-replication branch 2 times, most recently from 13b9369 to 1bd9d89 Compare October 1, 2024 09:23
@pav-kv pav-kv marked this pull request as ready for review October 1, 2024 09:24
@pav-kv pav-kv requested a review from a team as a code owner October 1, 2024 09:24
@pav-kv pav-kv requested review from tbg and sumeerbhola October 1, 2024 09:31
Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - appreciate the clean commits.

I'm mostly still unsure why it looks like we can send nonempty probes in lazy mode. Once that is resolved this PR is ready as far as I'm concerned.

pkg/raft/testdata/lazy_replication.txt Show resolved Hide resolved
pkg/raft/testdata/lazy_replication.txt Show resolved Hide resolved
pkg/raft/tracker/progress.go Show resolved Hide resolved
pkg/raft/tracker/progress.go Show resolved Hide resolved
This commits adds a prep test for the next commit, to demonstrate the
difference between the eager and lazy replication.

Epic: none
Release note: none
This commit adds support for LazyReplication mode in raft. In this mode,
the leader does not send MsgApp messages eagerly to StateReplicate
peers. Instead, the appends are requested explicitly by the application
layer, via the RawNode.SendMsgApp() method.

The application:
- monitors the replication flow state to all followers, e.g. using the
  RawNode.Status() method,
- for peers who have outstanding replication work, decides when and how
  much worth of the log to send out,
- fetches the log slice from the RawNode.LogSnapshot(),
- sends the appends using the RawNode.SendMsgApp() method.

Epic: none
Release note: none
Epic: none
Release note: none
Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 7 files at r5, 2 of 2 files at r6, 2 of 2 files at r7, 4 of 5 files at r8, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @iskettaneh and @tbg)

Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the explainers!

@pav-kv
Copy link
Collaborator Author

pav-kv commented Oct 2, 2024

bors r=tbg,sumeerbhola

@craig craig bot merged commit ae0fc32 into cockroachdb:master Oct 2, 2024
23 checks passed
@pav-kv pav-kv deleted the raft-lazy-replication branch October 2, 2024 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants