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: don't apply entries when applying snapshot #14721

Merged
merged 2 commits into from
Nov 14, 2022

Conversation

nvanbenschoten
Copy link
Contributor

@nvanbenschoten nvanbenschoten commented Nov 10, 2022

This commit removes the ability to apply log entries at the same time as applying a snapshot. Doing so it possible, but it leads to complex code and raises questions about what should be applied first. It also raises additional complexity when we start allowing concurrent, asynchronous log appends and log application. It's easiest to just disallow this.

Signed-off-by: Nathan VanBenschoten [email protected]

Extracted from #14627.

cc. @tbg

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@codecov-commenter
Copy link

codecov-commenter commented Nov 10, 2022

Codecov Report

Merging #14721 (bdd5347) into main (bdd5347) will not change coverage.
The diff coverage is n/a.

❗ Current head bdd5347 differs from pull request most recent head 539a841. Consider uploading reports for the commit 539a841 to get more accurate results

@@           Coverage Diff           @@
##             main   #14721   +/-   ##
=======================================
  Coverage   76.04%   76.04%           
=======================================
  Files         457      457           
  Lines       37350    37350           
=======================================
  Hits        28403    28403           
  Misses       7162     7162           
  Partials     1785     1785           
Flag Coverage Δ
all 76.04% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tbg
Copy link
Contributor

tbg commented Nov 11, 2022

Give me a ping when it's rebased, I'd like to glance at the diff again before merge. Thanks!

unstable.snapshot is never an empty snapshot. This check made it look
like it could be.

Signed-off-by: Nathan VanBenschoten <[email protected]>
This commit removes the ability to apply log entries at the same time as
applying a snapshot. Doing so it possible, but it leads to complex code and
raises questions about what should be applied first. It also raises additional
complexity when we start allowing concurrent, asynchronous log appends and log
application. It's easiest to just disallow this.

Signed-off-by: Nathan VanBenschoten <[email protected]>
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/noCommittedOnSnap branch from a3c7480 to 539a841 Compare November 11, 2022 18:58
@nvanbenschoten
Copy link
Contributor Author

Rebased on main now that #14719 is merged. PTAL!

@@ -181,9 +181,13 @@ func (l *raftLog) unstableEntries() []pb.Entry {
// If applied is smaller than the index of snapshot, it returns all committed
Copy link
Contributor

Choose a reason for hiding this comment

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

stale comment.

if l.committed+1 > off {
ents, err := l.slice(off, l.committed+1, l.maxNextCommittedEntsSize)
if l.hasPendingSnapshot() {
// See comment in hasNextCommittedEnts.
Copy link
Contributor

Choose a reason for hiding this comment

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

You could even structure this method as

  1. call hasNextCommittedEnts; if false, return early.
  2. otherwise, do the slice.

That way there's no duplication in logic between the two and one need not worry about them diverging via a future change.

Copy link
Member

Choose a reason for hiding this comment

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

+1

raft/log.go Show resolved Hide resolved
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM

Thank you @nvanbenschoten

@ahrtr ahrtr merged commit 970ecfc into etcd-io:main Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants