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
VSR: Ping releases #1670
VSR: Ping releases #1670
Changes from 1 commit
0319566
8a058d8
e1c4aff
5add306
135ba32
5beb02c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,9 @@ pub const CheckpointTrailerType = @import("vsr/checkpoint_trailer.zig").Checkpoi | |
/// For backwards compatibility through breaking changes (e.g. upgrading checksums/ciphers). | ||
pub const Version: u16 = 0; | ||
|
||
/// A ReleaseList is ordered from highest-to-lowest(i.e. newest-to-oldest) version. | ||
pub const ReleaseList = stdx.BoundedArray(u16, constants.vsr_releases_max); | ||
|
||
pub const ProcessType = enum { replica, client }; | ||
|
||
pub const Zone = enum { | ||
|
@@ -1044,6 +1047,18 @@ pub fn member_index(members: *const Members, replica_id: u128) ?u8 { | |
} else return null; | ||
} | ||
|
||
pub fn verify_release_list(releases: []const u16) void { | ||
assert(releases.len >= 1); | ||
assert(releases.len <= constants.vsr_releases_max); | ||
|
||
for ( | ||
releases[0 .. releases.len - 1], | ||
releases[1..], | ||
) |release_a, release_b| { | ||
assert(release_a > release_b); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This checks for the descending list, right? That is, that's the opposite of natural sort order? What's the reason for deviation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was to emphasize that the highest versions are higher priorities... in retrospect, probably an unnecessary complication. |
||
} | ||
} | ||
|
||
pub const Headers = struct { | ||
pub const Array = stdx.BoundedArray(Header.Prepare, constants.view_change_headers_max); | ||
/// The SuperBlock's persisted VSR headers. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,14 @@ pub fn ReplicaType( | |
/// It should never be modified by a running replica. | ||
release_client_min: u16, | ||
|
||
/// A list of all versions of code that are available in the current binary. | ||
/// Includes the current version, newer versions, and older versions. | ||
/// Ordered from highest/newest to lowest/oldest. | ||
/// | ||
/// Note that this is a property (rather than a constant) for the purpose of testing. | ||
/// It should never be modified for a running replica. | ||
releases_bundled: vsr.ReleaseList, | ||
|
||
/// A globally unique integer generated by a crypto rng during replica process startup. | ||
/// Presently, it is used to detect outdated start view messages in recovering head status. | ||
nonce: Nonce, | ||
|
@@ -487,6 +495,7 @@ pub fn ReplicaType( | |
grid_cache_blocks_count: u32 = Grid.Cache.value_count_max_multiple, | ||
release: u16, | ||
release_client_min: u16, | ||
releases_bundled: vsr.ReleaseList, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, but I'v bound bounded array to be clunky to work with (esp for vsr headers). Given that That is, I think the two stationary design points are:
Here we are sort-of in the middle, where the interface requires a |
||
}; | ||
|
||
/// Initializes and opens the provided replica using the options. | ||
|
@@ -548,6 +557,7 @@ pub fn ReplicaType( | |
.grid_cache_blocks_count = options.grid_cache_blocks_count, | ||
.release = options.release, | ||
.release_client_min = options.release_client_min, | ||
.releases_bundled = options.releases_bundled, | ||
}); | ||
|
||
// Disable all dynamic allocation from this point onwards. | ||
|
@@ -847,6 +857,7 @@ pub fn ReplicaType( | |
grid_cache_blocks_count: u32, | ||
release: u16, | ||
release_client_min: u16, | ||
releases_bundled: vsr.ReleaseList, | ||
}; | ||
|
||
/// NOTE: self.superblock must be initialized and opened prior to this call. | ||
|
@@ -889,6 +900,13 @@ pub fn ReplicaType( | |
// Flexible quorums are safe if these two quorums intersect so that this relation holds: | ||
assert(quorum_replication + quorum_view_change > replica_count); | ||
|
||
vsr.verify_release_list(options.releases_bundled.const_slice()); | ||
assert(std.mem.indexOfScalar( | ||
u16, | ||
options.releases_bundled.const_slice(), | ||
options.release, | ||
) != null); | ||
|
||
self.time = options.time; | ||
|
||
// The clock is special-cased for standbys. We want to balance two concerns: | ||
|
@@ -976,6 +994,7 @@ pub fn ReplicaType( | |
.quorum_majority = quorum_majority, | ||
.release = options.release, | ||
.release_client_min = options.release_client_min, | ||
.releases_bundled = options.releases_bundled, | ||
.nonce = options.nonce, | ||
// Copy the (already-initialized) time back, to avoid regressing the monotonic | ||
// clock guard. | ||
|
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.
vsr_releases_max
is a new config/constant which defines the maximum number of releases that can be advertised by a replica in aping
message. (So this is effectively the maximum number of releases that can be compiled into a multiversion binary).I set it to
64
right now, which I chose somewhat arbitrarily: We release on a weekly cadence, there are 52 weeks/year, rounded up to the nearest power-of-2 is 64.