Persist primitive life outcomes across control moves
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (client) (push) Successful in 12m36s
Foundation / checks (network) (push) Successful in 13m43s
Foundation / checks (tsan) (push) Successful in 8m14s
Foundation / checks (postgres) (push) Failing after 17m26s
Foundation / checks (checks) (push) Successful in 33m23s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (client) (push) Successful in 12m36s
Foundation / checks (network) (push) Successful in 13m43s
Foundation / checks (tsan) (push) Successful in 8m14s
Foundation / checks (postgres) (push) Failing after 17m26s
Foundation / checks (checks) (push) Successful in 33m23s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -626,7 +626,7 @@ reserve_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, con
|
||||
const auto identity = parse_integer<std::uint64_t>((*rows)[0][0]);
|
||||
const auto region = parse_integer<std::uint64_t>((*rows)[0][1]);
|
||||
const auto refusal = parse_integer<std::uint32_t>((*rows)[0][2]);
|
||||
if (!identity || *identity == 0 || !region || *region == 0 || !refusal || *refusal > 3)
|
||||
if (!identity || *identity == 0 || !region || *region == 0 || !refusal || *refusal > 4)
|
||||
return std::unexpected{unknown};
|
||||
return LifeReservation{*identity, *region, static_cast<LifeRefusal>(*refusal)};
|
||||
}
|
||||
@@ -690,6 +690,42 @@ load_primitive_lives(Postgres& db, RegionKey key, milliseconds timeout) {
|
||||
return out;
|
||||
}
|
||||
|
||||
std::expected<std::optional<PrimitiveLifeOutcome>, LifeReservationFailure>
|
||||
query_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, const Uuid& account,
|
||||
std::uint64_t generation, std::uint64_t request_id, milliseconds timeout) {
|
||||
const auto base = control_parameters(key, lease, account, generation);
|
||||
const std::array<std::string, 7> p{
|
||||
base[0], base[1], base[2], base[3], base[4], base[5], std::to_string(request_id)};
|
||||
auto rows = db.query("SELECT * FROM evolution.query_primitive_life($1::evolution.u64, "
|
||||
"$2::evolution.u64, $3::uuid, $4::evolution.u64, $5::uuid, "
|
||||
"$6::evolution.u64, $7::evolution.u64)",
|
||||
p, timeout);
|
||||
if (!rows)
|
||||
return std::unexpected{life_failure(rows.error())};
|
||||
if (rows->empty())
|
||||
return std::optional<PrimitiveLifeOutcome>{};
|
||||
const auto& row = (*rows)[0];
|
||||
if (rows->size() != 1 || row.size() != 6)
|
||||
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
|
||||
const auto identity = parse_integer<std::uint64_t>(row[0]);
|
||||
const auto region = parse_integer<std::uint64_t>(row[1]);
|
||||
const auto refusal = parse_integer<std::uint32_t>(row[2]);
|
||||
if (!identity || *identity == 0 || !region || *region == 0 || !refusal || *refusal > 4)
|
||||
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
|
||||
PrimitiveLifeOutcome out{
|
||||
LifeReservation{*identity, *region, static_cast<LifeRefusal>(*refusal)}, std::nullopt};
|
||||
if (row[3] || row[4] || row[5]) {
|
||||
const auto born = parse_integer<std::uint64_t>(row[3]);
|
||||
const auto commit = parse_uuid(row[4]);
|
||||
const auto sequence = parse_integer<std::uint64_t>(row[5]);
|
||||
if (!born || *born == 0 || !commit || !sequence || *sequence == 0)
|
||||
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
|
||||
out.published =
|
||||
PrimitiveLifeBinding{account, request_id, *identity, *born, *commit, *sequence};
|
||||
}
|
||||
return std::optional<PrimitiveLifeOutcome>{std::move(out)};
|
||||
}
|
||||
|
||||
// Schema v12 probe records and handoff (ADR-0096). Shares this file's parsing rules.
|
||||
namespace {
|
||||
ProbeStoreFailure probe_failure(const PgFailure& f) {
|
||||
|
||||
Reference in New Issue
Block a user