M12.4: retain migration source freezes and explicit aborts
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m24s
Foundation / checks (network) (push) Successful in 20m44s
Foundation / checks (client) (push) Successful in 22m3s
Foundation / checks (tsan) (push) Successful in 23m1s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 24m7s
Foundation / checks (postgres) (push) Canceled after 24m3s

This commit is contained in:
dingo
2026-10-18 09:08:50 -04:00
parent 1b5c0cdf7c
commit c625a4cb68
25 changed files with 1342 additions and 18 deletions
@@ -0,0 +1,45 @@
#pragma once
#include "evo/persistence/checkpoint_store.hpp"
#include "evo/server/lifecycle/cellular_migration_trace.hpp"
namespace evo::persistence {
struct CellularMigrationPrepared {
RegionKey key{}; // Source region.
std::vector<std::uint8_t> trace;
};
struct CellularMigrationFreeze {
server::CellularMigrationTrace trace;
bool aborted{};
};
struct CellularMigrationFailure {
PublicationError kind{};
LeaseStoreFailure store{};
ObjectError object{};
CellularMigrationPrepared prepared; // Exact request after unknown/rejection.
};
// Verify both complete cuts and the paired biology, retain a verified destination
// replay capsule in the source namespace, then freeze the exact source head.
// Neither candidate is published or activated by this operation.
[[nodiscard]] std::expected<CellularMigrationFreeze, CellularMigrationFailure>
prepare_cellular_migration_freeze(Postgres&, const FilesystemObjectStore& source_objects,
const FilesystemObjectStore& destination_objects,
const LeaseGrant& source_lease, const CommittedCheckpoint& source,
const CommittedCheckpoint& destination,
const server::CellularMigrationRequest&,
std::chrono::milliseconds timeout,
const PublishHooks& hooks = {});
[[nodiscard]] std::expected<CellularMigrationFreeze, CellularMigrationFailure>
retry_cellular_migration_freeze(Postgres&, const LeaseGrant&, const CellularMigrationPrepared&,
std::chrono::milliseconds timeout);
// Current source authority only. No timeout/lease-expiry auto-abort. The result
// repeats a retained abort and cannot reopen an old preparation.
[[nodiscard]] std::expected<CellularMigrationFreeze, LeaseStoreFailure>
abort_cellular_migration_freeze(Postgres&, RegionKey, const LeaseGrant&, const Uuid& request,
std::chrono::milliseconds timeout);
// Fenced lookup AND complete capsule replay. An empty result means no freeze;
// missing/corrupt evidence is an error, never implicit permission to advance.
[[nodiscard]] std::expected<std::optional<CellularMigrationFreeze>, RecoveryFailure>
load_cellular_migration_freeze(Postgres&, const FilesystemObjectStore&, RegionKey,
const LeaseGrant&, std::chrono::milliseconds timeout);
} // namespace evo::persistence
@@ -1,6 +1,7 @@
#pragma once
#include "evo/network/session_protocol.hpp"
#include "evo/persistence/cellular_migration_store.hpp"
#include "evo/persistence/checkpoint_store.hpp"
#include "evo/persistence/life_reservation_store.hpp"
#include "evo/persistence/population_checkpoint_store.hpp"
@@ -91,6 +92,14 @@ class CellularRegionHost {
// Acquires/renews authority, recovers fully, or resolves the exact pending commit.
const HostStatus& step();
// Explicit source-only preparation/abort. Preparation pauses the whole region;
// restart and lease expiry never imply abort or destination activation.
[[nodiscard]] std::expected<void, CellularPublishFailure>
prepare_migration_freeze(const persistence::CommittedCheckpoint& destination,
const persistence::FilesystemObjectStore& destination_objects,
const CellularMigrationRequest&);
[[nodiscard]] std::expected<void, CellularPublishFailure>
abort_migration_freeze(const persistence::Uuid& request);
// Explicit no-tick fenced transition. Uncertain publication pauses the host.
[[nodiscard]] std::expected<void, CellularPublishFailure> set_population_mode(bool enabled);
[[nodiscard]] bool population_mode() const noexcept;
@@ -154,6 +163,7 @@ class CellularRegionHost {
void refresh();
bool recover_state(const persistence::LeaseGrant&);
void reconcile_interval();
void reconcile_migration_freeze();
void finish_interval();
[[nodiscard]] std::expected<persistence::PublishedCellularBatch, CellularPublishFailure>
publish_population(const CellularBatch&);
@@ -215,6 +225,10 @@ class CellularRegionHost {
std::expected<persistence::CommittedCheckpoint, persistence::PopulationPublicationFailure>,
OwnedState candidate);
OwnedState state_;
bool migration_reload_{}, migration_frozen_{};
persistence::LeaseClock::time_point migration_poll_at_{};
std::optional<persistence::CellularMigrationPrepared> migration_request_;
std::optional<persistence::Uuid> migration_abort_;
bool interval_reload_{};
std::optional<persistence::PopulationInterval> admitted_interval_;
// An uncertain admission must retry its exact source/target, never select again.
+1
View File
@@ -38,6 +38,7 @@ struct HostStatus {
std::uint64_t commits{}, store_failures{}, unknown_outcomes{}, fences{};
// Local lease safety: time until this host must stop originating (0 = none).
std::uint64_t lease_remaining_ms{};
bool migration_frozen{}; // Known durable source freeze; expiry is not an abort.
};
// Process-level counters and bounds the exposition adds to the host status.