Skip to content

Commit

Permalink
vsr: synchronize op and commit_max updates on_prepare
Browse files Browse the repository at this point in the history
Before, op was updated first, and commit_max at the end, breaking

```
assert(self.commit_max >= self.op -| constants.pipeline_prepare_queue_max);
```

invariant

Seed: 1648503712295043012
  • Loading branch information
matklad committed Feb 20, 2024
1 parent 1120495 commit 763793e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/vsr/replica.zig
Expand Up @@ -1394,14 +1394,11 @@ pub fn ReplicaType(
assert(message.header.op > self.op);
assert(message.header.op > self.commit_min);

defer {
if (self.backup()) {
// A prepare may already be committed if requested by repair() so take the max:
self.advance_commit_max(message.header.commit, @src().fn_name);
self.commit_journal();
assert(self.commit_max >= message.header.commit);
}
if (self.backup()) {
self.advance_commit_max(message.header.commit, @src().fn_name);
assert(self.commit_max >= message.header.commit);
}
defer if (self.backup()) self.commit_journal();

// Verify that the new request will fit in the WAL.
if (message.header.op > self.op_prepare_max()) {
Expand Down Expand Up @@ -3030,7 +3027,6 @@ pub fn ReplicaType(
assert(self.commit_max == self.commit_min);
assert(self.commit_max == self.op - self.pipeline.queue.prepare_queue.count);
}

}

if (commit > self.commit_max) {
Expand Down

0 comments on commit 763793e

Please sign in to comment.