Publish cellular births with durable control
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 43s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (postgres) (push) Failing after 52s
Foundation / checks (tsan) (push) Failing after 32s
Foundation / checks (network) (push) Failing after 3m4s
Foundation / checks (client) (push) Failing after 4m24s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 43s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (postgres) (push) Failing after 52s
Foundation / checks (tsan) (push) Failing after 32s
Foundation / checks (network) (push) Failing after 3m4s
Foundation / checks (client) (push) Failing after 4m24s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -55,6 +55,7 @@ bool prepared_is_canonical(const CellularPreparedCommit& prepared,
|
||||
manifest.end_tick)
|
||||
: std::expected<std::vector<std::uint8_t>, server::CellularActionBlockError>{
|
||||
std::unexpected{server::CellularActionBlockError::format}};
|
||||
const auto encoded_trace = server::encode_cellular_batch(trace);
|
||||
const auto digest = sha256(prepared.trace);
|
||||
return manifest.profile == CheckpointProfile::cellular_lives_v1 &&
|
||||
manifest.key == prepared.key && manifest.commit == prepared.commit &&
|
||||
@@ -66,7 +67,8 @@ bool prepared_is_canonical(const CellularPreparedCommit& prepared,
|
||||
trace.header.predecessor == manifest.predecessor_commit &&
|
||||
trace.header.predecessor_digest == manifest.predecessor_digest &&
|
||||
trace.header.begin_tick == manifest.begin_tick && trace.header.end_tick == manifest.end_tick &&
|
||||
encoded_actions && *encoded_actions == prepared.actions;
|
||||
encoded_actions && *encoded_actions == prepared.actions && encoded_trace &&
|
||||
*encoded_trace == prepared.trace;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -135,7 +137,8 @@ retry_cellular_prepared(Postgres& db, const CellularPreparedCommit& prepared,
|
||||
auto trace = server::decode_cellular_batch(prepared.trace);
|
||||
if (!manifest || !trace || !prepared_is_canonical(prepared, *manifest, *trace))
|
||||
return std::unexpected{failure(PublicationError::candidate)};
|
||||
auto result = publish_cellular_checkpoint(db, prepared.manifest, {}, prepared.actions, timeout);
|
||||
auto result = publish_cellular_checkpoint(db, prepared.manifest, {}, prepared.actions,
|
||||
prepared.trace, timeout);
|
||||
if (!result) {
|
||||
return std::unexpected{failure(
|
||||
result.error().kind == LeaseStoreError::unknown ? PublicationError::unknown
|
||||
@@ -153,7 +156,7 @@ resolve_cellular_prepared(Postgres& db, const CellularPreparedCommit& prepared,
|
||||
if (!manifest || !trace || !prepared_is_canonical(prepared, *manifest, *trace))
|
||||
return std::unexpected{LeaseStoreFailure{LeaseStoreError::invalid, {}}};
|
||||
return resolve_cellular_region_commit(db, prepared.key, prepared.commit, prepared.manifest,
|
||||
{}, prepared.actions, timeout);
|
||||
{}, prepared.actions, prepared.trace, timeout);
|
||||
}
|
||||
|
||||
std::expected<PublishedCellularBatch, CellularPublicationFailure>
|
||||
@@ -278,6 +281,23 @@ recover_cellular_checkpoint(Postgres& db, const FilesystemObjectStore& objects,
|
||||
trace->header.end_tick != manifest->end_tick)
|
||||
return fail_with(RecoveryError::tail);
|
||||
|
||||
auto committed_births = load_cellular_publication_births(db, key, lease,
|
||||
manifest->commit, timeout);
|
||||
if (!committed_births)
|
||||
return std::unexpected{RecoveryFailure{RecoveryError::store,
|
||||
committed_births.error()}};
|
||||
std::vector<CellularBirthBinding> traced_births;
|
||||
for (std::size_t tick_index = 0; tick_index < trace->ticks.size(); ++tick_index) {
|
||||
for (const auto& birth : trace->ticks[tick_index].births) {
|
||||
traced_births.push_back({birth.account, manifest->commit, birth.request,
|
||||
birth.identity,
|
||||
manifest->begin_tick + tick_index + 1,
|
||||
manifest->sequence});
|
||||
}
|
||||
}
|
||||
if (traced_births != *committed_births)
|
||||
return fail_with(RecoveryError::history);
|
||||
|
||||
auto predecessor = load_region_commit(db, key, manifest->sequence - 1, timeout);
|
||||
if (!predecessor)
|
||||
return std::unexpected{RecoveryFailure{RecoveryError::tail, predecessor.error()}};
|
||||
|
||||
@@ -340,11 +340,13 @@ publish_region_checkpoint(Postgres& db, std::span<const std::uint8_t> manifest,
|
||||
std::expected<RegionHead, LeaseStoreFailure>
|
||||
publish_cellular_checkpoint(Postgres& db, std::span<const std::uint8_t> manifest,
|
||||
std::span<const std::uint8_t> decisions,
|
||||
std::span<const std::uint8_t> actions, milliseconds timeout) {
|
||||
const std::array<std::string, 3> p{bytea(manifest), bytea(decisions), bytea(actions)};
|
||||
std::span<const std::uint8_t> actions,
|
||||
std::span<const std::uint8_t> trace, milliseconds timeout) {
|
||||
const std::array<std::string, 4> p{bytea(manifest), bytea(decisions), bytea(actions),
|
||||
bytea(trace)};
|
||||
auto rows = db.query(
|
||||
"SELECT * FROM evolution.publish_cellular_checkpoint($1::bytea, $2::bytea, $3::bytea)",
|
||||
p, timeout);
|
||||
"SELECT * FROM evolution.publish_cellular_checkpoint($1::bytea, $2::bytea, $3::bytea, "
|
||||
"$4::bytea)", p, timeout);
|
||||
if (!rows)
|
||||
return std::unexpected{classify(rows.error())};
|
||||
auto head = parse_head(*rows);
|
||||
@@ -388,13 +390,14 @@ std::expected<ResolvedCommit, LeaseStoreFailure>
|
||||
resolve_cellular_region_commit(Postgres& db, RegionKey key, const Uuid& commit,
|
||||
std::span<const std::uint8_t> manifest,
|
||||
std::span<const std::uint8_t> decisions,
|
||||
std::span<const std::uint8_t> actions, milliseconds timeout) {
|
||||
const std::array<std::string, 6> p{std::to_string(key.world), std::to_string(key.region),
|
||||
std::span<const std::uint8_t> actions,
|
||||
std::span<const std::uint8_t> trace, milliseconds timeout) {
|
||||
const std::array<std::string, 7> p{std::to_string(key.world), std::to_string(key.region),
|
||||
uuid_text(commit), bytea(manifest),
|
||||
bytea(decisions), bytea(actions)};
|
||||
bytea(decisions), bytea(actions), bytea(trace)};
|
||||
auto rows = db.query(
|
||||
"SELECT * FROM evolution.resolve_cellular_region_commit($1::evolution.u64, "
|
||||
"$2::evolution.u64, $3::uuid, $4::bytea, $5::bytea, $6::bytea)",
|
||||
"$2::evolution.u64, $3::uuid, $4::bytea, $5::bytea, $6::bytea, $7::bytea)",
|
||||
p, timeout);
|
||||
if (!rows)
|
||||
return std::unexpected{classify(rows.error())};
|
||||
@@ -436,6 +439,36 @@ load_cellular_publication_actions(Postgres& db, RegionKey key, const LeaseGrant&
|
||||
return std::optional<std::vector<std::uint8_t>>{std::move(*actions)};
|
||||
}
|
||||
|
||||
std::expected<std::vector<CellularBirthBinding>, LeaseStoreFailure>
|
||||
load_cellular_publication_births(Postgres& db, RegionKey key, const LeaseGrant& lease,
|
||||
const Uuid& commit, milliseconds timeout) {
|
||||
const std::array<std::string, 5> p{std::to_string(key.world), std::to_string(key.region),
|
||||
uuid_text(lease.holder), std::to_string(lease.epoch),
|
||||
uuid_text(commit)};
|
||||
auto rows = db.query(
|
||||
"SELECT account_id::text, request_id::text, identity::text, born::text, "
|
||||
"commit_sequence::text FROM evolution.load_cellular_publication_births("
|
||||
"$1::evolution.u64, $2::evolution.u64, $3::uuid, $4::evolution.u64, $5::uuid)",
|
||||
p, timeout);
|
||||
if (!rows)
|
||||
return std::unexpected{classify(rows.error())};
|
||||
std::vector<CellularBirthBinding> bindings;
|
||||
bindings.reserve(rows->size());
|
||||
for (const auto& row : *rows) {
|
||||
if (row.size() != 5)
|
||||
return std::unexpected{malformed(false)};
|
||||
const auto account = parse_uuid(row[0]);
|
||||
const auto request = parse_integer<std::uint64_t>(row[1]);
|
||||
const auto identity = parse_integer<std::uint64_t>(row[2]);
|
||||
const auto born = parse_integer<std::uint64_t>(row[3]);
|
||||
const auto sequence = parse_integer<std::uint64_t>(row[4]);
|
||||
if (!account || !request || !identity || !born || !sequence)
|
||||
return std::unexpected{malformed(false)};
|
||||
bindings.push_back({*account, commit, *request, *identity, *born, *sequence});
|
||||
}
|
||||
return bindings;
|
||||
}
|
||||
|
||||
std::expected<std::optional<CommittedAction>, LeaseStoreFailure>
|
||||
find_region_action(Postgres& db, RegionKey key, const LeaseGrant& lease, const Uuid& account,
|
||||
std::uint64_t action_id, milliseconds timeout) {
|
||||
|
||||
Reference in New Issue
Block a user