feat: durable mutation queue (schema 59)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m24s
Foundation / postgres-tools (push) Successful in 1m31s
Foundation / server-image (push) Successful in 4m25s
Foundation / image (push) Successful in 4m50s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m24s
Foundation / postgres-tools (push) Successful in 1m31s
Foundation / server-image (push) Successful in 4m25s
Foundation / image (push) Successful in 4m50s
A mutation choice's reserved tick is now the earliest tick it may bind at, not the only one (ADR-0121 amendment). With write-behind commits, a choice reserved for head + 1 landed in ticks already being simulated or committed: the batch was refused, or the reservation was orphaned for a past tick and stalled the region. Schema 59: a bound record carries the tick it applied at and the rest of its input must equal the reservation's; the "omits a reserved mutation" refusals are removed. Existing rows are unchanged, so an orphaned reservation binds at the next commit that carries it. The host keeps every unbound reservation queued and the open batch binds those the commit in flight does not carry, at its next tick; the earlier hold on new choices is removed. A choice that outlives its life binds as life_died (owner, trace matching and recovery accept it when no life with that ID remains). Recovery takes a bound choice's tick from its trace. Tests: a choice skipped by one checkpoint binds a tick late and recovers; builder late binding, refusal before the earliest tick, and a departed life's life_died outcome. Full local PostgreSQL qualification passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+15
-16
@@ -1063,8 +1063,6 @@ int serve_cellular(Options& o) {
|
||||
if (batch_builder)
|
||||
session_status.simulated_tick =
|
||||
std::max(session_status.simulated_tick, batch_builder->candidate().tick());
|
||||
// Mutation choices are reserved only while nothing is simulated past the head.
|
||||
host.hold_mutation_selections(batch_builder.has_value() || host.commit_in_flight());
|
||||
bridge->poll(session_status, wall);
|
||||
deliver_finalized();
|
||||
set_ready(status.ready);
|
||||
@@ -1160,9 +1158,8 @@ int serve_cellular(Options& o) {
|
||||
}
|
||||
const auto flush_ticks = std::clamp<std::uint64_t>(
|
||||
static_cast<std::uint64_t>(o.host.flush_interval.count()) / 50, 1, 60);
|
||||
// Births and mutation choices wait for a batch that starts on the durable head.
|
||||
const bool admissions_waiting =
|
||||
!held_births.empty() || !host.queued_mutations().empty() || host.selections_held();
|
||||
// Births wait for a batch that starts on the durable head.
|
||||
const bool admissions_waiting = !held_births.empty();
|
||||
// Write-behind commit: the open batch goes to the host's worker thread and the next
|
||||
// batch continues from its candidate under a provisional head, rebased when the commit
|
||||
// lands. One commit is in flight; meanwhile the open batch simply keeps growing.
|
||||
@@ -1239,15 +1236,9 @@ int serve_cellular(Options& o) {
|
||||
// Rules 12 regions hold thousands of deposits, so their committed payload is
|
||||
// large: commit every flush interval (ADR-0089: 1 s), not every tick. Players
|
||||
// see the batch's working state at once; outcomes become final at its commit.
|
||||
// Births and mutation choices commit promptly, in their own fresh batch.
|
||||
// Births commit promptly, in their own fresh batch.
|
||||
if (batch_builder && admissions_waiting)
|
||||
flush();
|
||||
// The head is current: held choices reserve its next tick and join the
|
||||
// fresh batch below.
|
||||
if (!batch_builder && !host.commit_in_flight() && host.selections_held()) {
|
||||
host.hold_mutation_selections(false);
|
||||
host.admit_held_selections();
|
||||
}
|
||||
const auto* current = batch_builder ? &batch_builder->candidate() : state;
|
||||
// A failed commit can leave the host without state until it recovers. While a
|
||||
// commit is in flight the open batch is the only place to simulate, and it is
|
||||
@@ -1310,16 +1301,24 @@ int serve_cellular(Options& o) {
|
||||
if (!batch_builder) {
|
||||
bridge->dropped(actions, true);
|
||||
} else {
|
||||
// Births and mutation choices only ever enter a fresh batch on the
|
||||
// durable head.
|
||||
// Births only ever enter a fresh batch on the durable head. Queued
|
||||
// mutation choices (ADR-0121 amendment, schema 59) bind at the next
|
||||
// tick simulated, unless this batch or the commit in flight has them.
|
||||
const bool fresh =
|
||||
batch_builder->batch().ticks.empty() && !host.commit_in_flight();
|
||||
const std::span<const server::CellularTickIntents::Birth> births =
|
||||
fresh ? std::span<const server::CellularTickIntents::Birth>{held_births}
|
||||
: std::span<const server::CellularTickIntents::Birth>{};
|
||||
auto unbound = host.unbound_mutations();
|
||||
std::erase_if(unbound, [&](const auto& queued) {
|
||||
return std::ranges::any_of(
|
||||
batch_builder->mutation_actions(), [&](const auto& bound) {
|
||||
return bound.account == queued.account &&
|
||||
bound.action_id == queued.action_id;
|
||||
});
|
||||
});
|
||||
const std::span<const persistence::CellularMutationReservation> mutations =
|
||||
fresh ? host.queued_mutations()
|
||||
: std::span<const persistence::CellularMutationReservation>{};
|
||||
unbound;
|
||||
auto appended = batch_builder->append_with_birth_refusals(
|
||||
tick, baseline, actions, births, mutations);
|
||||
if (!appended && !actions.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user