M12.4: define explicit boundary-accounting checkpoint upgrades
Foundation / checks (deploy) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 2m38s
Foundation / checks (network) (push) Successful in 22m52s
Foundation / checks (client) (push) Successful in 23m48s
Foundation / checks (tsan) (push) Successful in 23m38s
Foundation / checks (postgres) (push) Successful in 53m31s
Foundation / checks (checks) (push) Successful in 1h9m6s
Foundation / postgres-tools (push) Successful in 2m0s
Foundation / server-image (push) Successful in 4m2s
Foundation / image (push) Successful in 4m40s
Foundation / checks (deploy) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 2m38s
Foundation / checks (network) (push) Successful in 22m52s
Foundation / checks (client) (push) Successful in 23m48s
Foundation / checks (tsan) (push) Successful in 23m38s
Foundation / checks (postgres) (push) Successful in 53m31s
Foundation / checks (checks) (push) Successful in 1h9m6s
Foundation / postgres-tools (push) Successful in 2m0s
Foundation / server-image (push) Successful in 4m2s
Foundation / image (push) Successful in 4m40s
This commit is contained in:
@@ -9,10 +9,10 @@ next_population(const CheckpointManifest& previous, const Sha256Digest& previous
|
||||
BatchDigests batch, bool transition) {
|
||||
if (!supported(previous) || !encode_manifest(previous) || previous.sequence == 0 ||
|
||||
previous.sequence == ~std::uint64_t{0} || previous.end_tick == 0 ||
|
||||
previous.cellular_versions != cellular_v9_versions || previous_digest == Sha256Digest{} ||
|
||||
lease.frame != previous.frame || lease.epoch == 0 || lease.holder == Uuid{} ||
|
||||
commit == Uuid{} || commit == previous.commit || end_tick < previous.end_tick ||
|
||||
end_tick - previous.end_tick > max_checkpoint_ticks ||
|
||||
population_envelope_version(previous.cellular_versions) == 0 ||
|
||||
previous_digest == Sha256Digest{} || lease.frame != previous.frame || lease.epoch == 0 ||
|
||||
lease.holder == Uuid{} || commit == Uuid{} || commit == previous.commit ||
|
||||
end_tick < previous.end_tick || end_tick - previous.end_tick > max_checkpoint_ticks ||
|
||||
(previous.profile != CheckpointProfile::cellular_lives_v1 &&
|
||||
previous.profile != CheckpointProfile::cellular_population_v1) ||
|
||||
(!transition && previous.profile != CheckpointProfile::cellular_population_v1))
|
||||
@@ -73,10 +73,71 @@ restore_population_payload(std::span<const std::uint8_t> payload, const Checkpoi
|
||||
return std::unexpected(state.error() == server::CellularPopulationError::unsupported
|
||||
? CheckpointError::unsupported
|
||||
: CheckpointError::payload);
|
||||
if ((*state)->format_version() != 1 ||
|
||||
if ((*state)->format_version() != population_envelope_version(m.cellular_versions) ||
|
||||
(*state)->state().format_version() != m.cellular_versions.envelope ||
|
||||
(*state)->state().rules_version() != m.cellular_versions.rules)
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
return std::move(*state);
|
||||
}
|
||||
|
||||
std::expected<CheckpointManifest, CheckpointError>
|
||||
cellular_boundary_upgrade_manifest(const CheckpointManifest& previous,
|
||||
const Sha256Digest& previous_digest, Uuid commit,
|
||||
const LeaseGrant& lease, const Sha256Digest& build,
|
||||
std::uint64_t bytes, const Sha256Digest& digest) {
|
||||
if (!supported(previous))
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
if (!encode_manifest(previous) || previous.sequence == 0 ||
|
||||
previous.sequence == ~std::uint64_t{0} || previous.end_tick == 0 ||
|
||||
previous.cellular_versions != cellular_v9_versions ||
|
||||
(previous.profile != CheckpointProfile::cellular_lives_v1 &&
|
||||
previous.profile != CheckpointProfile::cellular_population_v1) ||
|
||||
previous_digest == Sha256Digest{} || commit == Uuid{} || commit == previous.commit ||
|
||||
lease.frame != previous.frame || lease.epoch == 0 || lease.holder == Uuid{})
|
||||
return std::unexpected(CheckpointError::chain);
|
||||
auto next = previous;
|
||||
next.cellular_versions = cellular_v10_versions;
|
||||
next.commit = commit;
|
||||
++next.sequence;
|
||||
next.predecessor_commit = previous.commit;
|
||||
next.predecessor_digest = previous_digest;
|
||||
next.begin_tick = previous.end_tick;
|
||||
next.holder = lease.holder;
|
||||
next.epoch = lease.epoch;
|
||||
next.build = build;
|
||||
next.payload_bytes = bytes;
|
||||
next.payload_sha256 = digest;
|
||||
next.batch = {};
|
||||
if (!encode_manifest(next))
|
||||
return std::unexpected(CheckpointError::format);
|
||||
return next;
|
||||
}
|
||||
|
||||
std::expected<std::vector<std::uint8_t>, CheckpointError>
|
||||
cellular_boundary_upgrade_payload(std::span<const std::uint8_t> payload,
|
||||
const CheckpointManifest& previous) {
|
||||
if (!supported(previous) || previous.cellular_versions != cellular_v9_versions)
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
if (!encode_manifest(previous) || previous.sequence == 0 || previous.end_tick == 0)
|
||||
return std::unexpected(CheckpointError::chain);
|
||||
if (previous.profile == CheckpointProfile::cellular_lives_v1) {
|
||||
auto state = restore_cellular_payload(payload, previous);
|
||||
if (!state)
|
||||
return std::unexpected(state.error());
|
||||
auto upgraded = (*state)->migration_upgrade_candidate();
|
||||
if (!upgraded)
|
||||
return std::unexpected(CheckpointError::payload);
|
||||
return (*upgraded)->snapshot();
|
||||
}
|
||||
if (previous.profile == CheckpointProfile::cellular_population_v1) {
|
||||
auto state = restore_population_payload(payload, previous);
|
||||
if (!state)
|
||||
return std::unexpected(state.error());
|
||||
auto upgraded = (*state)->migration_upgrade_candidate();
|
||||
if (!upgraded)
|
||||
return std::unexpected(CheckpointError::payload);
|
||||
return (*upgraded)->snapshot();
|
||||
}
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
}
|
||||
} // namespace evo::persistence
|
||||
|
||||
Reference in New Issue
Block a user