Repository navigation
fix(start-os): carry out a restart or shutdown when a service fails to stop - #4736
Conversation
…o stop When one service failed to tear down, RpcContext::shutdown returned the error before marking the context closed, and startd's inner_main returned it before the power action it had already received. main then started Diagnostic Mode instead of running Shutdown::execute, so the server never rebooted, and a waiting `start-cli server restart` hung because wait_closed never resolved. RpcContext::shutdown now logs the teardown error, always closes the context and returns nothing, so the requested restart or shutdown goes ahead. The logged error names the package whose teardown failed. Fixes Start9Labs#4638 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
helix-white
left a comment
There was a problem hiding this comment.
Approved fc9331ee9. No correctness regressions found; the head merges cleanly with current master (422c9ea88).
A returned service-teardown error previously discarded an already accepted power action, entered Diagnostic Mode and stranded callers waiting for context closure. This change logs that error, publishes closure on both success and failure, and lets startd execute the accepted restart/shutdown. It also identifies each failing package in the aggregated error.
The existing concurrent service teardown, error collection and watch notification are retained. Every teardown attempt still finishes before closure is published; this does not bound a hung teardown or fix the underlying service-reference lifetime problem. There are no serialized API or storage changes.
Implementation diff: +21 / −8 lines in 3 files (excludes lockfiles, tests, docs, release notes, and changelog).
Verification evidence: The author records a passing make start-core-test on this head (1,500 core tests, 33 exver tests and three conversion-worker tests), formatting and version checks, and an x86_64 VM running this head's startbox over the StartOS 0.4.2.1 image. Killing filebrowser's container reproduced the base's stuck restart; the fixed build completed restart and shutdown, including reboot/poweroff. The focused regression covers closure after a returned error. The exact reported reference-holder failure and restart applying a staged OS update were not reproduced. I ran no builds or tests during review. Only metadata checks are attached to the PR; there is no substantive PR CI result to cite.
Related work: Open #4741 addresses shutdown admission and background-job ownership, not this error policy. Its current head conflicts with this PR in bins/startd.rs and context/rpc.rs; whichever lands second must preserve closure and power-action continuation after teardown errors.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
Both reviews now approve the unchanged head |
|
@only21mil please sign all commits for any future contributions |
|
Note 🤖 Opus 5.5 replying on behalf of Victor. Will do: my future commits here will be SSH-signed. Commits already pushed stay as they are. |
Problem
When one service fails to stop during a requested restart or shutdown, StartOS does not restart.
startdenters Diagnostic Mode, the reboot never runs, and a waitingstart-cli server restartnever returns. Expected: log the failure and still carry out the restart or shutdown.Change
RpcContext::shutdownreturned the teardown error before marking the context closed, andinner_mainreturned it before the power action it had already received.RpcContext::shutdownnow logs the error, always closes the context and returns nothing, sostartdgoes on toShutdown::executeand a waiting caller is released. Each service's teardown error now names its package, as a comment on #4527 asks.Scope
Bug fix: a requested restart or shutdown that never happens. Fixes #4638. Refs #4527, which reports the same failure. Why a teardown fails (both reports suspect a leaked
ServiceActorSeedreference) is not changed here.Verification
An AI agent made every run and check below.
Server: an x86_64 QEMU/KVM VM from the StartOS 0.4.2.1 release ISO, running
startboxbuilt per commit, with one service (filebrowser) whose container init each run killed first, so itsExitRPC fails. Commands ran undertimeout 300.2f845e5c4and the branch baseea61b7722,start-cli server restart: hung to the timeout (exit 124), the boot id did not change andstart-cli diagnostic errorreturned the teardown error.fc9331ee9and its local merge with2f845e5c4,start-cli server restart: under 0.1 s (exit 0). The journal shows the error, namingfilebrowser, thenBeginning server restart; the server rebooted into normal mode.start-cli server shutdown: under 0.1 s (exit 0), the same error, thenBeginning server shutdown; powered off 4 s later.Master when read,
9423bde5, changes only web UI files after2f845e5c4, so the runs stand for it. Its tests, formatting and generated artifacts passed; its one failure is the StartWRT version check; its image build was queued (below).git merge-treewith both is clean.Checks on
fc9331ee9(x86_64 Ubuntu 26.04):make start-core-test: 1500 start-core, 33exverand 3worker_tests passed, 0 failed. Earlier runs failed unrelated tests (below)./var/tmpon tmpfs: 1496 passed, 1779 on the merge;cargo check -p start-corepasses on both. The new test fails on the old behaviour.make format-check, changelog version check: pass.Not checked
server shutdownon the base, a restart that applies a staged OS update, several services failing at once,--nowaitand the web UI's buttons.ServiceActorSeed held somewhere after actor shutdownerror; a crashed container gave another error on the same path.Commands, check records and transcripts from the server
The new test,
failed_teardown_still_closes_the_context, fails on the old behaviour withassertion failed: is_closed.load(Ordering::SeqCst). That run usedea61b7722with only the new helper extracted (behaviour unchanged), because the helper the test calls is new.Checks, each run by an AI agent on x86_64 Ubuntu 26.04. "The merge" is a local merge of
fc9331ee9into2f845e5c4,3e0e832c3, never pushed.make start-core-testonfc9331ee9, the final run, with Docker's storage on ext4:exver33 passed; start-core 1500 passed, 0 failed, 29 ignored, 10 filtered out (--skip export_); its second step,backup::target::conversion::tests::worker_with--ignored, 3 passed; exit 0.make start-core-test, two earlier runs onfc9331ee9while the containers' filesystems were still on the host's XFS root. The first:exver33 passed; start-core 1498 passed, 2 failed, 29 ignored; theworker_step did not run, because the recipe stops at the first failing step.util::squashfs::source::tests::gnu_sparse_versions_and_old_extensionsfailed withspool lost holes for 0.0: its spool file under/var/tmpwas allocated past half its length on XFS.tunnel::web::listener::tests::ui_ipv6_and_dual_stack_listeners_remain_reachablefailed withAddress already in use: it binds port 0, drops it and binds that port again, so a parallel test can take it. The second: start-core 1499 passed, 1 failed (the sparse-file test), 29 ignored. This change touches neither test.make format-checkonfc9331ee9: pass. Before it,FMT_NATIVE=1 make start-core-format-check,prettier@3.8.3 --checkon the fragment andnode scripts/changelog.mjs check-version projects/start-os: each exit 0.cargo check -p start-core --lockedonfc9331ee9and on the merge: exit 0.cargo test -p start-core --features=test --locked --lib context::rpc::tests: 4 passed onfc9331ee9, 5 on the merge.--skip export_, in a private mount namespace with/var/tmpon tmpfs: 1496 passed, 0 failed, 29 ignored onfc9331ee9; 1779 passed, 0 failed, 37 ignored on the merge. The ignored tests are marked#[ignore]in the repo; most need root, Btrfs test volumes or network capabilities.fc9331ee9with/var/tmpon the host's XFS: 1495 passed, 1 failed (the sparse-file test above). Under abwrapuser namespace with/var/tmpon tmpfs: 1495 passed, 1 failed,util::squashfs::source::tests::directory_skips_posix_acl_and_retains_user_xattrs, which could not set an ACL entry for an id that namespace does not map (Invalid argument). It passes in the other runs.backup::target::conversion::tests::worker_with--ignored, natively onfc9331ee9: 3 passed.git merge-tree --write-treeoffc9331ee9with2f845e5c4and with9423bde5: both clean. The fix's files are identical in the two merged trees.fc9331ee9, natively with/var/tmpon XFS: 0 passed, 1 failed (exit 101). The same test from the recipe's release test binary in a container, before and after the containers' storage moved to ext4: exit 101, then exit 0. The firstnpm cibeforemake format-check, with Node 22: failed withENOENT(exit 254); with Node 24, the version rootAGENTS.mdnames, it passed andpackage-lock.jsonwas unchanged. Before the branch was squashed: the new test and the format checks on the uncommitted fix overea61b7722, and the changed module's tests on its first commitff9eb99cb: pass. Before runs on upstream mastere2eb3b973andd4e4420e6: the same hang as the base. A controlstart-cli server restartonfc9331ee9with no fault: 0.866 s (exit 0), then a reboot. One base before run and the first basestartboxbuild were cut off from outside before a result. Three VM harness attempts stopped before a result (a process check, a boot-readiness check, a VNC port still in use) and were repeated once each. A sparse-file probe in a container after the first storage switch, which had not yet moved the containers' storage, kept its hole; it tests the host, not this change. The firstmake start-core-testcall onfc9331ee9was stopped by its agent during cargo's dependency fetch, before any compile or test, with no result; the call started after it is the first recipe run above.make test(it adds the SDK, container-runtime and shell suites); this change touches only start-core.Upstream master
9423bde5, check runs read 2026-11-14 04:54 UTC: 8, all completed. 6 success:Run Automated Tests,Formatting & Lockfiles,Generated Artifacts,Dependency Licenses,Prettier,Publish to alpha apt. 1 skipped:Detect non-docs changes. 1 failure:Changelog fragments & versions, withchangelog: projects/start-wrt: version '1.4.0' does not match expected '1.4.1' from latest stable origin release '1.4.0' and pending fragments; the same check fails the same way on2f845e5c4. ItsDebian-based ISO and SquashFSworkflow run was pending. The one commit from2f845e5c4to it, #4725, changes five files underprojects/start-os/web/ui/and nothing in the Rust sources. The runs were made on2f845e5c4, whereRun Automated TestsandGenerated Artifactswere cancelled when #4725 landed.In the master before run, the journal command printed nothing because upstream now logs that error from
startd.rs:181;start-cli diagnostic errorshows it. The unmodified 0.4.2.1 image behaved as the two before runs did (a trial with a 180 s timeout).Before, upstream master
2f845e5c4, same steps as the base run below:Before, base
ea61b7722(one journal command whose output carries terminal colour codes is left out; the same lines follow with the codes stripped):After,
fc9331ee9, same steps:After,
fc9331ee9, same fault,start-cli server shutdown:After, the merge
3e0e832c3, same steps as the restart run above:After, the merge
3e0e832c3, same fault,start-cli server shutdown:Generated with Claude Opus 5.5 in T3 Code Nightly