-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
server: Save consistency index and term to backend even when they decease #13903
Conversation
…rease Reason to store CI and term in backend was to make db fully independent snapshot, it was never meant to interfere with apply logic. Skip of CI was introduced for v2->v3 migration where we wanted to prevent it from decreasing when replaying wal in etcd-io#5391. By mistake it was added to apply flow during refactor in etcd-io#12855 (comment). Consistency index and term should only be negotiated and used by raft to make decisions. Their values should only driven by raft state machine and backend should only be responsible for storing them.
Codecov Report
@@ Coverage Diff @@
## main #13903 +/- ##
==========================================
- Coverage 72.39% 70.49% -1.90%
==========================================
Files 469 469
Lines 38402 38389 -13
==========================================
- Hits 27802 27064 -738
- Misses 8813 9492 +679
- Partials 1787 1833 +46
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
if term < oldTerm { | ||
return | ||
} | ||
if index > oldi { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: I would consider being defensive. Something like this:
verify.Assert(func() {
oldi, _ := UnsafeReadConsistentIndex(tx)
if index <= oldi {
lg.Fatalf("Attempt to apply transaction at <= index detected...");
}
} );
- This shouldn't be implemented on Term (maybe in 3.6)
- This should clearly 'fail'/'panic' instead of failing silently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, will prepare a PR.
I am thinking this PR might not be fixing the issue, because etcd will always skip smaller consistent_index, see server.go#L1816. So this PR will change nothing. |
This issue was caused by term field, not consistent_index. Removal of consistent_index check was done in addition, as both checks were incorrect from Raft point of view. |
Do you mean it's possible that the term in an apply entry might be smaller than the existing term in bucket |
Reason to store CI and term in backend was to make db fully independent
snapshot, it was never meant to interfere with apply logic. Skip of CI
was introduced for v2->v3 migration where we wanted to prevent it from
decreasing when replaying wal in
#5391. By mistake it was added to
apply flow during refactor in
#12855 (comment).
Consistency index and term should only be negotiated and used by raft to make
decisions. Their values should only driven by raft state machine and
backend should only be responsible for storing them.
Fixes #13514
cc @ptabor @ahrtr @spzala