Repository navigation
fix(command): retry interrupted blocking reads during main upgrade - #1848
Merged
Merged
Conversation
`Channel::read_message_blocking_timeout` reads with `SO_RCVTIMEO`, which Linux never restarts after a handled signal even under `SA_RESTART` (signal(7)), and it retried only `WouldBlock`. A whole-cgroup SIGTERM reaching a replacement main waiting for COMMIT made it exit "waiting for commit" while the old main was already fenced, stopping the proxy abruptly. Retry `Interrupted` against the unchanged deadline. `open_pid_file` created a missing pid file before PREPARED, so a rolled-back upgrade left an empty pid file behind. Only check the parent directory's access for a missing file and create it at publish, after COMMIT. Make the compatibility-matrix skip visible without `--nocapture`. Refs #1846 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 4, 2026
…trix skip (#1854) Follow-up to #1848 (merged as c0edfa8). `util::open_pid_file` checked a missing pid file through the parent of the configured path, but `O_CREAT` in `util::publish_pid_file` follows a dangling symlink and creates its final target. A link into a missing directory passed the pre-PREPARED check, the upgrade committed, and the post-COMMIT create failed with ENOENT and was only logged. The check now follows the link chain (bounded at MAXSYMLINKS) and tests the final target's parent, still creating nothing. Failures that cannot be detected without creating a file (ENOSPC, quota, an LSM denial) stay logged after COMMIT; the residual risk is documented on `open_pid_file`. The compatibility-matrix skip message was written with an unbuffered `writeln!`, one write(2) per format piece, which libtest's progress output and the parallel case interleaved with. It is now formatted first and written with a single `write_all`, framed by newlines. Signed-off-by: Florentin Dubois <[email protected]>
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.
Follow-up to #1846 (merged as 7e2ebc0).
Problem
waiting for commitwhile the old main is already fenced: the proxy stops abruptly instead of softly. ThePausedCommandHub::handle_sigtermdoc comment claimed such a signal is honoured by the new Hub's event loop.okwhen skipped, and its skip message is captured by libtest.Cause
Channel::read_message_blocking_timeout(command/src/channel.rs) reads withSO_RCVTIMEO. signal(7): such a socket read is never restarted after a handled signal, even underSA_RESTART, so it fails withEINTR. The loop retried onlyWouldBlockand returnedChannelError::Read(Interrupted).util::open_pid_file(bin/src/util.rs) opened withcreate(true)before PREPARED. Child-side cleanup cannot fix this: the old main SIGKILLs the child on PREPARED timeout, unexpected message, or pending SIGTERM.println!is captured by libtest, and libtest has no skipped outcome.Fix
ErrorKind::Interrupted => continue. The deadline is still checked against theInstantcaptured at entry at the top of every iteration, so the wait is neither aborted nor extended. Callers:bin/src/upgrade.rs), plus the old main's PREPARED and ACTIVATED waits (bin/src/command/upgrade.rs). All three run with the SA_RESTART SIGTERM handler installed.sozu ctl(bin/src/ctl/command.rs, including the unboundedNonewait): installs no handler, so it never sees EINTR.sozu top: installs actrlchandler, but each of its reads is bounded at 5 s.access(W_OK | X_OK), which fails on a missing parent, a non-directory, EROFS or EACCES, andpublish_pid_filecreates the file after COMMIT. An existing file is still opened before PREPARED without truncation, so the directory-at-path rollback inupgrade_pid_file_failure_e2estill fails before PREPARED.std::io::stderr()directly, which bypasses libtest capture.The
handle_sigtermdoc comment now describes the retry. CHANGELOG[Unreleased]Fixed is updated.Tests
read_message_blocking_with_timeout_survives_interrupting_signalsandread_message_blocking_with_timeout_keeps_its_deadline_under_signalsinstall anSA_RESTARTSIGUSR1handler andpthread_killthe reader thread every 5 ms. Without the fix, both fail withRead(Os { code: 4, kind: Interrupted, ... }). With the fix, they pass in three consecutive runs.open_pid_file_defers_creating_a_missing_file_until_publishfails when the oldcreate(true)is restored and passes with the fix. Also added:open_pid_file_keeps_an_existing_file_until_publishandopen_pid_file_rejects_a_missing_parent_directory.cargo test -p sozu -p sozu-command-lib --all-features --lockedcargo test -p sozu --all-features -- --ignored, includingunwritable_pid_file_rolls_back_main_upgrade_and_keeps_servingandsigterm_during_prepare_aborts_upgrade_then_stops_the_old_maincargo clippy --all-features --all-targets -p sozu -p sozu-command-lib -- -D warningscargo +nightly fmt --all --checkcheck_doc_citations.py --base origin/mainRefs #1846