fix(server): hold mutation choices while ticks past the head are open
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m27s
Foundation / postgres-tools (push) Successful in 25s
Foundation / server-image (push) Successful in 4m9s
Foundation / image (push) Successful in 4m33s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m27s
Foundation / postgres-tools (push) Successful in 25s
Foundation / server-image (push) Successful in 4m9s
Foundation / image (push) Successful in 4m33s
A choice reserves the tick after the committed head. With an open batch or a background commit, that tick was already being simulated: the batch committed without the choice (refused, losing its ticks) or, racing the reservation, committed past it and left a reservation for a tick that had gone, which stalled the region at its next fresh batch. While a batch is open or a commit is in flight, the host now holds new choices and answers not_ready (the client repeats them every 2 s). The loop commits what it holds, waits for the head, then reserves the held choices and starts a fresh batch with them. A queued choice the builder still refuses makes the host reload its queue instead of stalling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1063,6 +1063,8 @@ 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);
|
||||
@@ -1159,7 +1161,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();
|
||||
const bool admissions_waiting =
|
||||
!held_births.empty() || !host.queued_mutations().empty() || host.selections_held();
|
||||
// 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,6 +1242,12 @@ int serve_cellular(Options& o) {
|
||||
// Births and mutation choices 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
|
||||
@@ -1333,6 +1342,8 @@ int serve_cellular(Options& o) {
|
||||
const auto lives = batch_builder->last_lives_error();
|
||||
report_stall("append", appended.error(), tick,
|
||||
lives ? static_cast<int>(*lives) : -1);
|
||||
if (appended.error() == server::CellularSessionBatchError::mutation)
|
||||
host.recheck_mutations();
|
||||
bridge->dropped(actions, true);
|
||||
flush(); // Commit what is good; the next tick starts afresh.
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user