Guard cellular host optional results
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m54s
Foundation / checks (client) (push) Successful in 13m21s
Foundation / checks (network) (push) Successful in 15m14s
Foundation / checks (tsan) (push) Successful in 8m35s
Foundation / checks (checks) (push) Successful in 36m29s
Foundation / checks (postgres) (push) Failing after 23m14s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

This commit is contained in:
dingo
2026-10-11 14:14:52 -04:00
parent 9b7e3b4fca
commit 8a9a318d78
2 changed files with 19 additions and 7 deletions
+11 -7
View File
@@ -297,7 +297,9 @@ const HostStatus& CellularRegionHost::step() {
std::expected<persistence::PublishedCellularBatch, CellularHostError>
CellularRegionHost::publish(const CellularBatch& batch,
std::span<const CellularActionRecord> actions) {
if (!status_.ready || !state_ || !committed_ || !authority_.may_begin_commit(LeaseClock::now()))
const auto grant = authority_.grant();
if (!status_.ready || !state_ || !committed_ || !grant ||
!authority_.may_begin_commit(LeaseClock::now()))
return std::unexpected{CellularHostError::not_ready};
auto candidate = replay_cellular_batch(*state_, batch);
if (!candidate)
@@ -310,8 +312,8 @@ CellularRegionHost::publish(const CellularBatch& batch,
if (!commit)
return std::unexpected{CellularHostError::invalid_batch};
auto published = persistence::publish_cellular_batch(
*db_, *objects_, *authority_.grant(), *committed_, batch, **candidate, *commit,
config_.build, config_.lease.commit_timeout, {}, actions);
*db_, *objects_, grant.value_or(persistence::LeaseGrant{}), *committed_, batch, **candidate,
*commit, config_.build, config_.lease.commit_timeout, {}, actions);
if (!published) {
if (published.error().kind == persistence::PublicationError::unknown) {
pending_ = std::make_unique<Pending>(Pending{published.error().prepared,
@@ -389,7 +391,7 @@ network::PrimitiveLifeOutcome CellularRegionHost::query_birth(const persistence:
}
if (!queried->has_value())
return unknown();
const auto& outcome = queried->value();
const auto outcome = queried->value_or(persistence::PrimitiveLifeOutcome{});
if (outcome.published)
return {request, PrimitiveLifeResult::born, outcome.published->identity,
outcome.published->commit_sequence};
@@ -449,9 +451,11 @@ void CellularRegionHost::drain() {
status_.phase = HostPhase::draining;
pending_.reset();
const auto grant = authority_.grant();
if (grant && authority_.may_originate(LeaseClock::now()) && database())
static_cast<void>(persistence::release_region_lease(*db_, config_.key, *grant,
config_.lease.renew_timeout));
if (grant && authority_.may_originate(LeaseClock::now()) && database()) {
// Best effort during shutdown; the lease expires if release cannot be confirmed.
[[maybe_unused]] const auto released = persistence::release_region_lease(
*db_, config_.key, *grant, config_.lease.renew_timeout);
}
authority_.fence();
state_.reset();
committed_.reset();