Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m50s
Foundation / checks (network) (push) Successful in 9m8s
Foundation / checks (client) (push) Successful in 12m10s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 7m33s
Foundation / checks (checks) (push) Canceled after 18m49s
Foundation / checks (tsan) (push) Canceled after 6m38s
Migration v10 keeps, per world and account, the highest accepted grant serial and the region session in control with a fencing generation and database-time expiry, reachable only through claim/renew/release functions under the caller's region lease. Serials survive restarts and apply across regions; a cross-region takeover returns a wait so control never overlaps. RegionSessions takes durable control via a ControlLedger before admitting a session, delays Welcome by the wait, renews, and closes sessions whose control is fenced or cannot be confirmed in time. PostgresControlLedger implements the ledger. ADR-0091. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.8 KiB
C++
35 lines
1.8 KiB
C++
#pragma once
|
|
#include "evo/network/session_control.hpp"
|
|
#include "evo/persistence/account_control_store.hpp"
|
|
#include <chrono>
|
|
#include <functional>
|
|
#include <optional>
|
|
#include <utility>
|
|
|
|
// M10.3c durable account control over the region's PostgreSQL lease (ADR-0091, schema v10).
|
|
// Linux only. Owned by the region host's thread, on the host's own connection. `lease`
|
|
// returns the host's current region lease, or nothing while it holds none (every call then
|
|
// reports `fenced`). Store failures that may have executed or are undecided report
|
|
// `unavailable`; the session layer then keeps or closes sessions by its own deadlines.
|
|
namespace evo::server {
|
|
class PostgresControlLedger final : public network::ControlLedger {
|
|
public:
|
|
using LeaseSource = std::function<std::optional<persistence::LeaseGrant>()>;
|
|
PostgresControlLedger(persistence::Postgres& db, persistence::RegionKey key, LeaseSource lease,
|
|
std::chrono::milliseconds duration = std::chrono::milliseconds{20000},
|
|
std::chrono::milliseconds timeout = std::chrono::milliseconds{2000})
|
|
: db_{&db}, key_{key}, lease_{std::move(lease)}, duration_{duration}, timeout_{timeout} {}
|
|
[[nodiscard]] std::expected<network::ControlLease, network::ControlLedgerError>
|
|
claim(const network::AccountId& account, std::uint64_t serial, std::uint64_t session) override;
|
|
[[nodiscard]] std::expected<std::chrono::milliseconds, network::ControlLedgerError>
|
|
renew(const network::AccountId& account, std::uint64_t generation) override;
|
|
void release(const network::AccountId& account, std::uint64_t generation) override;
|
|
|
|
private:
|
|
persistence::Postgres* db_;
|
|
persistence::RegionKey key_;
|
|
LeaseSource lease_;
|
|
std::chrono::milliseconds duration_, timeout_;
|
|
};
|
|
} // namespace evo::server
|