Complete M7.9b upgrade barrier and durability qualification
Schema v8 binds authority to builds (ADR-0068): acquisition names the host build and only retained, unretired builds may hold a lease; no commit may name a retired build; upgrade_barrier retires a build and fences every holder in one transaction, while build-less pre-v8 hosts keep working until the first barrier. Tests cover a writer surviving a failed and then a real online migration, old-writer fencing on every path, whole-history recovery by the new build, and the M7 qualification fixture (19.6 s SIGKILL-to-ready under the production lease, no lost acknowledgements). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -131,12 +131,14 @@ std::optional<RegionHead> parse_head(const PgRows& rows, std::size_t columns = 5
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::expected<LeaseGrant, LeaseStoreFailure>
|
||||
acquire_region_lease(Postgres& db, RegionKey key, milliseconds duration, milliseconds timeout) {
|
||||
const std::array<std::string, 3> p{std::to_string(key.world), std::to_string(key.region),
|
||||
std::to_string(duration.count())};
|
||||
std::expected<LeaseGrant, LeaseStoreFailure> acquire_region_lease(Postgres& db, RegionKey key,
|
||||
const Sha256Digest& build,
|
||||
milliseconds duration,
|
||||
milliseconds timeout) {
|
||||
const std::array<std::string, 4> p{std::to_string(key.world), std::to_string(key.region),
|
||||
std::to_string(duration.count()), bytea(build)};
|
||||
auto rows = db.query("SELECT * FROM evolution.acquire_region_lease($1::evolution.u64, "
|
||||
"$2::evolution.u64, $3::integer)",
|
||||
"$2::evolution.u64, $3::integer, $4::bytea)",
|
||||
p, timeout);
|
||||
if (!rows)
|
||||
return std::unexpected{classify(rows.error())};
|
||||
|
||||
@@ -138,10 +138,12 @@ template <typename State> void RegionHost<State>::acquire(SchedulerTime now) {
|
||||
// A grant survives a transient recovery failure; only re-acquire without one.
|
||||
if (!authority_.may_originate(LeaseClock::now())) {
|
||||
const auto sent = LeaseClock::now();
|
||||
auto grant = persistence::acquire_region_lease(*db_, config_.key, config_.lease.duration,
|
||||
config_.lease.renew_timeout);
|
||||
auto grant = persistence::acquire_region_lease(
|
||||
*db_, config_.key, config_.build, config_.lease.duration, config_.lease.renew_timeout);
|
||||
if (!grant) {
|
||||
if (grant.error().kind == LeaseStoreError::not_provisioned)
|
||||
// No region, or this build is retired/unknown (ADR-0068): never serve.
|
||||
if (grant.error().kind == LeaseStoreError::not_provisioned ||
|
||||
grant.error().kind == LeaseStoreError::unsupported)
|
||||
status_.phase = HostPhase::quarantined;
|
||||
else if (grant.error().kind != LeaseStoreError::busy)
|
||||
db_.reset();
|
||||
|
||||
Reference in New Issue
Block a user