Skip to content

Commit

Permalink
vsr: reset sync_view when sync is done
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Mar 15, 2024
1 parent de8f1e5 commit 84bc115
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/vsr/replica.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3819,16 +3819,17 @@ pub fn ReplicaType(
// Thus, the SuperBlock's `commit_min` is set to 7-2=5.
const vsr_state_commit_min = self.op_checkpoint_next();

const vsr_state_sync_op: struct { min: u64, max: u64 } = sync: {
const vsr_state_sync: struct { op_min: u64, op_max: u64, view: u32 } = sync: {
if (self.sync_content_done()) {
assert(self.sync_tables == null);
assert(self.grid_repair_tables.executing() == 0);

break :sync .{ .min = 0, .max = 0 };
break :sync .{ .op_min = 0, .op_max = 0, .view = 0 };
} else {
break :sync .{
.min = self.superblock.staging.vsr_state.sync_op_min,
.max = self.superblock.staging.vsr_state.sync_op_max,
.op_min = self.superblock.staging.vsr_state.sync_op_min,
.op_max = self.superblock.staging.vsr_state.sync_op_max,
.view = self.superblock.staging.vsr_state.view,
};
}
};
Expand All @@ -3852,8 +3853,9 @@ pub fn ReplicaType(
.{
.header = self.journal.header_with_op(vsr_state_commit_min).?.*,
.commit_max = self.commit_max,
.sync_op_min = vsr_state_sync_op.min,
.sync_op_max = vsr_state_sync_op.max,
.sync_op_min = vsr_state_sync.op_min,
.sync_op_max = vsr_state_sync.op_max,
.sync_view = vsr_state_sync.view,
.manifest_references = self.state_machine.forest.manifest_log.checkpoint_references(),
.free_set_reference = self.grid.free_set_checkpoint.checkpoint_reference(),
.client_sessions_reference = self.client_sessions_checkpoint.checkpoint_reference(),
Expand Down
3 changes: 3 additions & 0 deletions src/vsr/superblock.zig
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ pub const SuperBlockHeader = extern struct {
pub fn assert_internally_consistent(state: VSRState) void {
assert(state.commit_max >= state.checkpoint.header.op);
assert(state.sync_op_max >= state.sync_op_min);
if (state.sync_op_max == 0) assert(state.sync_view == 0);
assert(state.view >= state.log_view);
assert(state.replica_count > 0);
assert(state.replica_count <= constants.replicas_max);
Expand Down Expand Up @@ -813,6 +814,7 @@ pub fn SuperBlockType(comptime Storage: type) type {
commit_max: u64,
sync_op_min: u64,
sync_op_max: u64,
sync_view: u32,
manifest_references: ManifestReferences,
free_set_reference: TrailerReference,
client_sessions_reference: TrailerReference,
Expand Down Expand Up @@ -871,6 +873,7 @@ pub fn SuperBlockType(comptime Storage: type) type {
vsr_state.commit_max = update.commit_max;
vsr_state.sync_op_min = update.sync_op_min;
vsr_state.sync_op_max = update.sync_op_max;
vsr_state.sync_view = update.sync_view;
assert(superblock.staging.vsr_state.would_be_updated_by(vsr_state));

context.* = .{
Expand Down

0 comments on commit 84bc115

Please sign in to comment.