Repository navigation
fix(command): roll back unacknowledged replay entries and bound the load-state fan-out (#1313) - #1325
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 15, 2026 12:15
…oad-state fan-out (#1313) `LoadState` and `ReloadConfiguration` dispatched every saved entry into the main `ConfigState` before the fan-out and judged the whole batch by one fleet-wide ok/errors tally, with no rollback: an entry every worker rejected stayed in the master state, was re-persisted by `SaveState` and re-injected on every replay. Both load tasks now gather per entry, attribute worker answers by the scatter id `{worker_id}-{task_id}-{request_index}`, and revert each entry no worker acknowledged with the inverse `compute_rollback` computed at scatter time, under the same `should_rollback_fanout` predicate as the live path. The same paths could also hang forever with no answer to the client: they scattered with `Timeout::None`, a request that could not be written to a worker channel was dropped while still counted as expected, a worker closed with requests in flight answered nothing, and a large state file overflowed the worker back buffer frame by frame. Undeliverable requests and the in-flight requests of a closing worker are now accounted as `Failure`, an answered request leaves the in-flight map immediately, a per-worker pending queue drains the overflow from the event loop's writable path without blocking the supervisor, and both load tasks arm a bounded deadline scaled by the entry count and reported as a failure. Unit tests in `bin/src/command/{requests,server}.rs` were seen red before the fix; `bin/tests/load_state_rollback_e2e.rs` replays a poisoned state file against a real master. CI now runs `cargo test -p sozu`. Closes #1313 Signed-off-by: Florentin Dubois <[email protected]>
A replay entry that ConfigState refuses was skipped silently on both load paths, and a worker Failure only bumped a counter. At startup there is no client to carry the reason, so the log line is the only trace: warn on the dispatch refusal, count it with the validation skips, and warn once per worker rejection with the worker id and entry index. Signed-off-by: Florentin Dubois <[email protected]>
…ocess-level suites in CI Replay a state file larger than max_command_buffer_size against a real master and worker: the load answers within its deadline, no entry is refused by the worker channel, the saved state holds every frontend and the worker routes the last one. A mixed file keeps its accepted entries, drops the rejected one and reports the reverted count. The three bin/tests/*_e2e.rs suites stay #[ignore]d for a fast local cargo test and now run from a dedicated CI step; before it they ran nowhere. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/load-state-rollback
branch
from
September 15, 2026 12:48
867543b to
ec80031
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1313 — the rollback half left open after #1315, plus the "no responses at all" hang reported in the issue thread.
Cause
LoadState(sozu state load) andReloadConfigurationdispatched every saved entry into the mainConfigStatebefore the fan-out and judged the whole batch by one fleet-wideok/errorstally:LoadStateTask::on_finishnever touchedserver.state, so an entry every worker rejected stayed in the master state, was re-persisted bySaveStateand re-injected on every replay. The live single-request path has had a unanimous-rejection rollback since #1302/#1316; the replay paths had none.Both load paths also scattered with
Timeout::None, and three accounting holes could keepok + errorsshort ofexpected_responsesforever: a request the master could not write to a worker channel was dropped while still counted as expected; a worker closed with requests in flight answered nothing; and a state file larger than the worker back buffer (max_command_buffer_size, 2 MB) had its entries refused frame by frame. Any of them left the task, and the CLI waiting on it, without an answer.Fix
PerEntryGathererattributes every worker answer to its replay entry through the scatter id{worker_id}-{task_id}-{request_index}, capturescompute_rollbackat scatter time, andon_finishreverts exactly the entries no worker acknowledged under the existingshould_rollback_fanoutpredicate. An entry at least one worker acknowledged is never reverted. Applied toLoadStateTaskandLoadStaticConfigTask.worker_timeoutplus 10 ms per scattered entry, capped at tenworker_timeouts, re-armed after parsing; a timeout is reported to the client as a failure and audited witherror_code=worker_timeout.Failurefor the owning task (the liveWorkerTaskbenefits too). An answered request leaves the in-flight map immediately, so a worker that answers and then dies does not turn a successful replay into a failed one.WorkerSessionparks what does not fit in a per-workerpendingqueue and drains it in order from the event loop's writable path. The supervisor never blocks on a worker socket; the buffer ceiling is unchanged.Tests
bin/src/command/requests.rsload_state_rollback_testsandbin/src/command/server.rstests: per-entry revert, timed-out replay, attribution, unqueued-request accounting, worker-close accounting without double counting, 500-entry scatter through a 4 KiB ceiling delivered in order. All seen red before the fix (recipes in the module docs).bin/tests/load_state_rollback_e2e.rs(#[ignore], run with-- --ignored): replays a state file carrying a frontend on an address with no listener against a real master with one worker, then assertsstate saveno longer contains it and thatstate loadanswered within a bounded time.bin/tests/load_state_rollback_e2e.rsalso replays a state file larger thanmax_command_buffer_size(lowered to 16 KiB in the test config):state loadanswers within its deadline, the master log shows no refused entry, the saved state holds all 200 frontends and the worker routes the last one (seen red with the pending queue disabled); and a mixed file keeps its accepted entries, drops the rejected one and reportsreverted entries: 1.warn!whenConfigStaterefuses an entry (both load paths, counted with the validation skips) and onewarn!per worker rejection with worker id and entry index..github/workflows/ci.ymlgainscargo test -p sozuand aTest sozu (process-level e2e)step running the threebin/tests/*_e2e.rssuites with-- --ignored; before it they ran nowhere.sozu_top_e2estays out: it needs thetuifeature no matrix cell enables.Verification
Docs updated in the same change:
CHANGELOG.md,bin/src/command/LIFECYCLE.md,doc/observability.md.Known residual:
UpgradeWorkerTaskstill usesTimeout::None; it now benefits from the synthetic-failure accounting but keeps no deadline, out of scope here.