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

fix applied upper bound #543

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/raft_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,15 @@ impl<T: Storage> RaftLog<T> {
if idx == 0 {
return;
}
if idx > self.applied_index_upper_bound() || idx < self.applied {
// NOTE: here we must use `commmitted` instead of `min(committed, perssited + max_apply_unpersisted_log_limit)`
// as the uppper bound because the `max_apply_unpersisted_log_limit` can be adjusted dynamically.
if idx > self.committed || idx < self.applied {
fatal!(
self.unstable.logger,
"applied({}) is out of range [prev_applied({}), min(committed({}), persisted({}))]",
"applied({}) is out of range [prev_applied({}), committed({})]",
idx,
self.applied,
self.committed,
self.persisted,
)
}
self.applied_to_unchecked(idx);
Expand Down Expand Up @@ -1250,6 +1251,8 @@ mod test {
(5, 5, 5, 0, None),
(5, 7, 7, UNLIMITED, Some(&ents[2..4])),
(7, 7, 7, UNLIMITED, None),
// test applied can be bigger than `persisted + limit`(when limit is changed)
(8, 6, 8, 0, None),
];
for (i, &(applied, persisted, committed, limit, ref expect_entries)) in
tests.iter().enumerate()
Expand Down
Loading