Repository navigation
fix(command): roll back a fanned-out change when the scatter times out unacknowledged - #1316
Merged
Merged
Conversation
FlorentinDUBOIS
changed the base branch from
fix/router-trie-insert-panic
to
main
August 27, 2026 21:03
FlorentinDUBOIS
enabled auto-merge
August 27, 2026 21:04
FlorentinDUBOIS
force-pushed
the
fix/rollback-on-unanimous-timeout
branch
from
August 27, 2026 21:25
9355c0d to
710364d
Compare
…t unacknowledged The unanimous-rejection rollback added for sozu#1301 was gated on `!timed_out && expected > 0 && ok == 0 && errors > 0`, so it was skipped whenever the fan-out ended through its timeout instead of through `has_finished`. That guard assumed a rejecting worker answers, and a panicking one does not: `handle_worker_close` marks the worker `Stopped` without injecting a synthetic `Failure` and without decrementing `expected_responses`, so `ok + errors >= expected` never becomes true and the task can only end on the deadline. `errors > 0` therefore cannot express "no worker took this change". The consequence is the incident shape of sozu#1314: during a rolling upgrade a single worker still running an unpatched build panics on a malformed frontend hostname, the request times out, the revert is skipped, and the malformed entry stays committed in the main process's `ConfigState` — the authoritative state replayed into every restarted or upgraded worker, and re-persisted by `SaveState` — even though the operator was already told the command failed. Extract the decision into `should_rollback_fanout(timed_out, expected, ok, errors)` and widen it to `expected > 0 && ok == 0 && (errors > 0 || timed_out)`: revert on either trigger as long as NO worker acknowledged the change. `ok == 0` remains the safety bound, so an entry at least one worker applied is still never reverted and the main process never diverges from the workers that accepted it. The rollback log lines carry counts only — a `RequestHttpFrontend` rendering would leak the operator-supplied hostname. Accepted residual: a slow-but-healthy worker whose `Ok` lands after the deadline is invisible to the finished task, so it keeps the frontend until its next restart or state replay while the main process reverts. That divergence is bounded, self-heals on replay, and matches the failure already reported to the client — strictly better than permanently committing an entry no worker confirmed. `WorkerTask::on_finish` needs a real `&mut Server` and the deadline lives in the event loop, so the guarantee is composed rather than simulated: `handle_finishing_task_forwards_timed_out_flag` pins the propagation of `timed_out` into `on_finish`, and the new `rollback_predicate_tests` pin the decision that flag feeds. Same shape as sozu#1301, where only `compute_rollback` is unit-tested. Branches off the sozu#1312 frontend-hostname fix, which is what makes a worker answer `Failure` instead of dying; this closes the timeout hole in the sozu#1301 safety-net for every rejection class, including fleets that are mid-upgrade. Fixes #1314 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/rollback-on-unanimous-timeout
branch
from
August 27, 2026 21:32
710364d to
f2ca5e3
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.
Problem
The #1301 unanimous-rejection rollback in
WorkerTask::on_finishonly fired on!timed_out && expected > 0 && ok == 0 && errors > 0— it required at least one worker to actually answerFailure. A worker that panics never answers at all:close_worker/handle_worker_closemark itStoppedwithout injecting a syntheticFailureand without decrementingexpected_responses, sohas_finished(ok + errors >= expected) never becomes true and the task can only end through the scatter's own timeout branch, which reportstimed_out=true. In that shapeerrors > 0is never satisfied, the rollback never fires, and a malformed frontend that every worker effectively rejected (one by panicking, one silently) stays committed in the main process'sConfigStateforever —SaveStatere-persists it on every subsequent save, even though the client was already told the command failed.Fix
Extracts the rollback decision into a small, exhaustively-tested pure predicate and widens its trigger to cover both ways a fan-out can end with zero acknowledgements:
ok == 0remains the safety bound: a change at least one worker accepted is never reverted, timeout or not — the main process must never diverge from a worker that already applied the change.expected == 0(a local-only request) never reverts, unchanged from Invalid HTTPS listener config is committed to master state before the worker rejects it, blocking a corrected reload #1301.Failure(the original Invalid HTTPS listener config is committed to master state before the worker rejects it, blocking a corrected reload #1301 case, unchanged) or a scatter that timed out with nothing but silence/failures (the new case, which is what a panicking worker produces).Both the revert and the non-revert error log lines were also corrected to report counts only (
ok=0, errors=N, expected=M, timed_out=bool), never request content — the #1301-era strings claimed "after all worker(s) rejected it", which stopped being accurate once the timeout path could reach the same branch. A few stale doc-comments describing the old "unanimous rejection" trigger were updated to match.Residual behaviour, documented in the code: a slow-but-healthy worker whose
Okarrives after the deadline is invisible to the already-finished task, so it keeps the frontend locally while the main process reverts. This is a bounded divergence — it self-heals on that worker's next restart or state replay, and it matches the failure already reported to the client.Tests
Six exhaustive unit cases for the extracted predicate (
rollback_predicate_tests): a clean fan-out (never rolls back), a local-only fan-out (never rolls back), any acknowledgement present (never rolls back regardless of timeout), unanimous rejection (rolls back — #1301, unchanged), a timeout with zero answers at all (rolls back — new), and a timeout with only failure answers (rolls back — new).A real scatter timeout can't be unit-simulated (
on_finishneeds a live&mut Serverand the deadline lives in the event loop), so the guarantee is composed of this predicate (the decision) plus the existinghandle_finishing_task_forwards_timed_out_flagtest (the propagation) — the same split #1301 used aroundcompute_rollback.RED — predicate first introduced as the exact pre-fix expression (
!timed_out && expected > 0 && ok == 0 && errors > 0):Exactly the two timeout cases fail; the four cases matching pre-existing behaviour stay green.
GREEN — fix restored, same unmodified command:
Commands run
cargo test -p sozu --locked→ ok, 72 passed, 0 failed (plus the pre-existing#[ignore]d e2e test, untouched)cargo clippy -p sozu --all-targets --locked -- -D warnings→ cleancargo +nightly fmt --all -- --check→ cleanNotes
Based on #1312 — will be retargeted/rebased onto main once it merges.
Fixes #1314