Skip to content

fix(start-os): carry out a restart or shutdown when a service fails to stop - #4736

Merged
dr-bonez merged 1 commit into
Start9Labs:masterfrom
only21mil:fix/restart-after-failed-teardown
Nov 19, 2026
Merged

dr-bonez merged 1 commit into
Start9Labs:masterfrom
only21mil:fix/restart-after-failed-teardown

Conversation

@only21mil

@only21mil only21mil commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When one service fails to stop during a requested restart or shutdown, StartOS does not restart. startd enters Diagnostic Mode, the reboot never runs, and a waiting start-cli server restart never returns. Expected: log the failure and still carry out the restart or shutdown.

Change

RpcContext::shutdown returned the teardown error before marking the context closed, and inner_main returned it before the power action it had already received. RpcContext::shutdown now logs the error, always closes the context and returns nothing, so startd goes on to Shutdown::execute and 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 ServiceActorSeed reference) 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 startbox built per commit, with one service (filebrowser) whose container init each run killed first, so its Exit RPC fails. Commands ran under timeout 300.

  • Upstream master 2f845e5c4 and the branch base ea61b7722, start-cli server restart: hung to the timeout (exit 124), the boot id did not change and start-cli diagnostic error returned the teardown error.
  • fc9331ee9 and its local merge with 2f845e5c4, start-cli server restart: under 0.1 s (exit 0). The journal shows the error, naming filebrowser, then Beginning server restart; the server rebooted into normal mode.
  • The same two builds, start-cli server shutdown: under 0.1 s (exit 0), the same error, then Beginning server shutdown; powered off 4 s later.

Master when read, 9423bde5, changes only web UI files after 2f845e5c4, 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-tree with both is clean.

Checks on fc9331ee9 (x86_64 Ubuntu 26.04):

  • make start-core-test: 1500 start-core, 33 exver and 3 worker_ tests passed, 0 failed. Earlier runs failed unrelated tests (below).
  • start-core lib suite, /var/tmp on tmpfs: 1496 passed, 1779 on the merge; cargo check -p start-core passes on both. The new test fails on the old behaviour.
  • make format-check, changelog version check: pass.

Not checked

  • server shutdown on the base, a restart that applies a staged OS update, several services failing at once, --nowait and the web UI's buttons.
  • The reporters' own ServiceActorSeed held somewhere after actor shutdown error; a crashed container gave another error on the same path.
  • Real hardware, other architectures, CI-built images.
Commands, check records and transcripts from the server

The new test, failed_teardown_still_closes_the_context, fails on the old behaviour with assertion failed: is_closed.load(Ordering::SeqCst). That run used ea61b7722 with 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 fc9331ee9 into 2f845e5c4, 3e0e832c3, never pushed.

  • make start-core-test on fc9331ee9, the final run, with Docker's storage on ext4: exver 33 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 on fc9331ee9 while the containers' filesystems were still on the host's XFS root. The first: exver 33 passed; start-core 1498 passed, 2 failed, 29 ignored; the worker_ step did not run, because the recipe stops at the first failing step. util::squashfs::source::tests::gnu_sparse_versions_and_old_extensions failed with spool lost holes for 0.0: its spool file under /var/tmp was allocated past half its length on XFS. tunnel::web::listener::tests::ui_ipv6_and_dual_stack_listeners_remain_reachable failed with Address 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-check on fc9331ee9: pass. Before it, FMT_NATIVE=1 make start-core-format-check, prettier@3.8.3 --check on the fragment and node scripts/changelog.mjs check-version projects/start-os: each exit 0.
  • cargo check -p start-core --locked on fc9331ee9 and on the merge: exit 0.
  • cargo test -p start-core --features=test --locked --lib context::rpc::tests: 4 passed on fc9331ee9, 5 on the merge.
  • The whole lib suite from each of those test binaries, --skip export_, in a private mount namespace with /var/tmp on tmpfs: 1496 passed, 0 failed, 29 ignored on fc9331ee9; 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.
  • The same suite on fc9331ee9 with /var/tmp on the host's XFS: 1495 passed, 1 failed (the sparse-file test above). Under a bwrap user namespace with /var/tmp on 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 on fc9331ee9: 3 passed.
  • git merge-tree --write-tree of fc9331ee9 with 2f845e5c4 and with 9423bde5: both clean. The fix's files are identical in the two merged trees.
  • Other attempts, each made by an AI agent: the sparse-file test alone on fc9331ee9, natively with /var/tmp on 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 first npm ci before make format-check, with Node 22: failed with ENOENT (exit 254); with Node 24, the version root AGENTS.md names, it passed and package-lock.json was unchanged. Before the branch was squashed: the new test and the format checks on the uncommitted fix over ea61b7722, and the changed module's tests on its first commit ff9eb99cb: pass. Before runs on upstream master e2eb3b973 and d4e4420e6: the same hang as the base. A control start-cli server restart on fc9331ee9 with no fault: 0.866 s (exit 0), then a reboot. One base before run and the first base startbox build 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 first make start-core-test call on fc9331ee9 was 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.
  • Not run: the whole-repository 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, with changelog: 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 on 2f845e5c4. Its Debian-based ISO and SquashFS workflow run was pending. The one commit from 2f845e5c4 to it, #4725, changes five files under projects/start-os/web/ui/ and nothing in the Rust sources. The runs were made on 2f845e5c4, where Run Automated Tests and Generated Artifacts were 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 error shows 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:

$ sudo start-cli git-info
2f845e5c41d9e3f8244f09476f7da0d178b4e18d
$ sudo start-cli package list
[
  {
    "status": "installed",
    "id": "filebrowser",
    "version": "2.63.23:6"
  }
]
$ sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
YNAJMGWEZE5UUD3RSPW5QRCZMAGJMX5H RUNNING 0
$ cat /proc/sys/kernel/random/boot_id
b565811f-8498-46ab-a4e2-21f933897cfc
$ C=$(sudo lxc-ls -1); sudo kill -KILL $(sudo lxc-info -n "$C" -p -H); sleep 2; sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
YNAJMGWEZE5UUD3RSPW5QRCZMAGJMX5H STOPPED 0
$ date -u +%T; time timeout 300 sudo start-cli server restart; echo "exit=$?"; date -u +%T
03:24:04

real	5m0.011s
user	0m0.013s
sys	0m0.026s
exit=124
03:29:04
$ cat /proc/sys/kernel/random/boot_id
b565811f-8498-46ab-a4e2-21f933897cfc
$ sudo journalctl -u startd -b -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -A9 'startd.rs:175: Multiple Errors'
$ sudo start-cli diagnostic error 2>&1 | grep -E "rpc exited|details"
rpc exited with code 54: Multiple Errors
    "details": String("Unknown Error: Connection refused (os error 111)"),
$ cat /proc/sys/kernel/random/boot_id; systemctl is-active startd
b565811f-8498-46ab-a4e2-21f933897cfc
active

Before, base ea61b7722 (one journal command whose output carries terminal colour codes is left out; the same lines follow with the codes stripped):

$ sudo start-cli git-info
ea61b77228cbaee7777f238b934802464452d653
$ sudo start-cli package list
[
  {
    "status": "installed",
    "id": "filebrowser",
    "version": "2.63.23:6"
  }
]
$ sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
3MNW2XY3IKVJZ46LHIQJZYPTXRENRAFS RUNNING 0
$ cat /proc/sys/kernel/random/boot_id
55e4ab9d-099d-4775-820d-ea4176da14fa
$ C=$(sudo lxc-ls -1); sudo kill -KILL $(sudo lxc-info -n "$C" -p -H); sleep 2; sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
3MNW2XY3IKVJZ46LHIQJZYPTXRENRAFS STOPPED 0
$ date -u +%T; time timeout 300 sudo start-cli server restart; echo "exit=$?"; date -u +%T
22:15:06

real	5m0.004s
user	0m0.014s
sys	0m0.012s
exit=124
22:20:06
$ cat /proc/sys/kernel/random/boot_id
55e4ab9d-099d-4775-820d-ea4176da14fa
$ sudo start-cli diagnostic error 2>&1 | grep -E "rpc exited|details"
rpc exited with code 54: Multiple Errors
    "details": String("Unknown Error: Connection refused (os error 111)"),
$ sudo journalctl -u startd -b -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -A9 'startd.rs:175: Multiple Errors'
2026-11-13T22:15:06.495332Z ERROR start_core::bins::startd: shared-libs/crates/start-core/src/bins/startd.rs:175: Multiple Errors: Unknown Error: Connection refused (os error 111)
2026-11-13T22:15:06.495342Z DEBUG start_core::bins::startd: shared-libs/crates/start-core/src/bins/startd.rs:176: Multiple Errors:
   0: Unknown Error: Connection refused (os error 111)
Location:
   shared-libs/crates/start-core/src/error.rs:574
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   0: start_core::context::rpc::shutdown
      at shared-libs/crates/start-core/src/context/rpc.rs:526
   1: start_core::bins::startd::inner_main
      at shared-libs/crates/start-core/src/bins/startd.rs:27
$ cat /proc/sys/kernel/random/boot_id; systemctl is-active startd
55e4ab9d-099d-4775-820d-ea4176da14fa
active

After, fc9331ee9, same steps:

$ sudo start-cli git-info
fc9331ee9454249c9d8a42284a10af9f759f7a48
$ sudo start-cli package list
[
  {
    "status": "installed",
    "id": "filebrowser",
    "version": "2.63.23:6"
  }
]
$ sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
QJAJLQ7NCV3FPLGBDWO366LDNNZI7KNN RUNNING 0
$ cat /proc/sys/kernel/random/boot_id
46bb39e6-6b71-4dd6-8772-8515f334f95a
$ C=$(sudo lxc-ls -1); sudo kill -KILL $(sudo lxc-info -n "$C" -p -H); sleep 2; sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
QJAJLQ7NCV3FPLGBDWO366LDNNZI7KNN STOPPED 0
$ date -u +%T; time timeout 300 sudo start-cli server restart; echo "exit=$?"; date -u +%T
22:35:44

real	0m0.057s
user	0m0.009s
sys	0m0.017s
exit=0
22:35:44
$ cat /proc/sys/kernel/random/boot_id; uptime -s
1bdd9d85-bb33-42e2-a632-ce2b3b0dd689
2026-11-13 22:35:54
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -A9 'ERROR inner_main:shutdown'
2026-11-13T22:35:44.113209Z ERROR inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:675: Multiple Errors: Unknown Error: filebrowser: Connection refused (os error 111)
2026-11-13T22:35:44.113225Z DEBUG inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:676: Multiple Errors:
   0: Unknown Error: filebrowser: Connection refused (os error 111)
Location:
   shared-libs/crates/start-core/src/error.rs:574
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   0: start_core::context::rpc::shutdown
      at shared-libs/crates/start-core/src/context/rpc.rs:536
   1: start_core::bins::startd::inner_main
      at shared-libs/crates/start-core/src/bins/startd.rs:27
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -E 'RpcContext is shutdown|Beginning server restart|Error Exporting Volume Group' | cut -c1-160
2026-11-13T22:35:44.113243Z  INFO inner_main:shutdown: start_core::context::rpc: shared-libs/crates/start-core/src/context/rpc.rs:545: RpcContext is shutdown
2026-11-13T22:35:44.123178Z  INFO start_core::shutdown: shared-libs/crates/start-core/src/shutdown.rs:23: Beginning server restart
2026-11-13T22:35:44.219756Z ERROR start_core::shutdown: shared-libs/crates/start-core/src/shutdown.rs:62: Error Exporting Volume Group: Disk Management Error: D
$ sudo start-cli diagnostic error 2>&1 | head -2
Not Found: Method not found
$ sudo start-cli git-info; systemctl is-active startd
fc9331ee9454249c9d8a42284a10af9f759f7a48
active

After, fc9331ee9, same fault, start-cli server shutdown:

$ sudo start-cli git-info
fc9331ee9454249c9d8a42284a10af9f759f7a48
$ sudo start-cli package list
[
  {
    "status": "installed",
    "id": "filebrowser",
    "version": "2.63.23:6"
  }
]
$ sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
2W6XYOEO4OFDXAYQGTSFI3GOYF7KGANW RUNNING 0
$ cat /proc/sys/kernel/random/boot_id
09646ee9-45c1-4600-b122-eacfa9f3d164
$ C=$(sudo lxc-ls -1); sudo kill -KILL $(sudo lxc-info -n "$C" -p -H); sleep 2; sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
2W6XYOEO4OFDXAYQGTSFI3GOYF7KGANW STOPPED 0
$ date -u +%T; time timeout 300 sudo start-cli server shutdown; echo "exit=$?"; date -u +%T
23:03:14

real	0m0.090s
user	0m0.018s
sys	0m0.011s
exit=0
23:03:14
[host] qemu process exited 4 s after the call
$ cat /proc/sys/kernel/random/boot_id; uptime -s
1aae1059-0bc5-4015-afed-0e734fed06e6
2026-11-13 23:03:34
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -A9 'ERROR inner_main:shutdown'
2026-11-13T23:03:14.989640Z ERROR inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:675: Multiple Errors: Unknown Error: filebrowser: Connection refused (os error 111)
2026-11-13T23:03:14.989663Z DEBUG inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:676: Multiple Errors:
   0: Unknown Error: filebrowser: Connection refused (os error 111)
Location:
   shared-libs/crates/start-core/src/error.rs:574
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   0: start_core::context::rpc::shutdown
      at shared-libs/crates/start-core/src/context/rpc.rs:536
   1: start_core::bins::startd::inner_main
      at shared-libs/crates/start-core/src/bins/startd.rs:27
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -E 'RpcContext is shutdown|Beginning server shutdown|Beginning server restart' | cut -c1-160
2026-11-13T23:03:14.989695Z  INFO inner_main:shutdown: start_core::context::rpc: shared-libs/crates/start-core/src/context/rpc.rs:545: RpcContext is shutdown
2026-11-13T23:03:15.002088Z  INFO start_core::shutdown: shared-libs/crates/start-core/src/shutdown.rs:25: Beginning server shutdown
$ sudo start-cli diagnostic error 2>&1 | head -2
Not Found: Method not found
$ sudo start-cli git-info; systemctl is-active startd
fc9331ee9454249c9d8a42284a10af9f759f7a48
active

After, the merge 3e0e832c3, same steps as the restart run above:

$ sudo start-cli git-info
3e0e832c3162b427450ca61999ee49f8839e8904
$ sudo start-cli package list
[
  {
    "status": "installed",
    "id": "filebrowser",
    "version": "2.63.23:6"
  }
]
$ sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
WQ4DC6ABE5KR7Z4WVJQAGN25KF5U2ICH RUNNING 0
$ cat /proc/sys/kernel/random/boot_id
5382d498-b10a-4439-88bb-b06941844bd8
$ C=$(sudo lxc-ls -1); sudo kill -KILL $(sudo lxc-info -n "$C" -p -H); sleep 2; sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
WQ4DC6ABE5KR7Z4WVJQAGN25KF5U2ICH STOPPED 0
$ date -u +%T; time timeout 300 sudo start-cli server restart; echo "exit=$?"; date -u +%T
03:32:28

real	0m0.079s
user	0m0.025s
sys	0m0.022s
exit=0
03:32:28
$ cat /proc/sys/kernel/random/boot_id; uptime -s
5c5b45a5-d281-4cba-8a0e-64604fb4c4c4
2026-11-14 03:32:41
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -A9 'ERROR inner_main:shutdown'
2026-11-14T03:32:28.656866Z ERROR inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:675: Multiple Errors: Unknown Error: filebrowser: Connection refused (os error 111)
2026-11-14T03:32:28.656884Z DEBUG inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:676: Multiple Errors:
   0: Unknown Error: filebrowser: Connection refused (os error 111)
Location:
   shared-libs/crates/start-core/src/error.rs:574
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   0: start_core::context::rpc::shutdown
      at shared-libs/crates/start-core/src/context/rpc.rs:605
   1: start_core::bins::startd::inner_main
      at shared-libs/crates/start-core/src/bins/startd.rs:27
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -E 'RpcContext is shutdown|Beginning server restart|Error Exporting Volume Group' | cut -c1-160
2026-11-14T03:32:28.656905Z  INFO inner_main:shutdown: start_core::context::rpc: shared-libs/crates/start-core/src/context/rpc.rs:614: RpcContext is shutdown
2026-11-14T03:32:28.677977Z  INFO start_core::shutdown: shared-libs/crates/start-core/src/shutdown.rs:23: Beginning server restart
2026-11-14T03:32:28.807966Z ERROR start_core::shutdown: shared-libs/crates/start-core/src/shutdown.rs:62: Error Exporting Volume Group: Disk Management Error: D
$ sudo start-cli diagnostic error 2>&1 | head -2
Not Found: Method not found
$ sudo start-cli git-info; systemctl is-active startd
3e0e832c3162b427450ca61999ee49f8839e8904
active

After, the merge 3e0e832c3, same fault, start-cli server shutdown:

$ sudo start-cli git-info
3e0e832c3162b427450ca61999ee49f8839e8904
$ sudo start-cli package list
[
  {
    "status": "installed",
    "id": "filebrowser",
    "version": "2.63.23:6"
  }
]
$ sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
H3ZPNNP7YQIEQEZSS44JB4MYKF2TQBNX RUNNING 0
$ cat /proc/sys/kernel/random/boot_id
b8f8d146-a565-47b9-ae25-3fd3bb3dae21
$ C=$(sudo lxc-ls -1); sudo kill -KILL $(sudo lxc-info -n "$C" -p -H); sleep 2; sudo lxc-ls -f | cut -c1-42
NAME                             STATE   A
H3ZPNNP7YQIEQEZSS44JB4MYKF2TQBNX STOPPED 0
$ date -u +%T; time timeout 300 sudo start-cli server shutdown; echo "exit=$?"; date -u +%T
03:40:30

real	0m0.064s
user	0m0.027s
sys	0m0.020s
exit=0
03:40:30
[host] qemu process exited 4 s after the call
$ cat /proc/sys/kernel/random/boot_id; uptime -s
e9f2cdc4-d968-4931-b6b7-c2574a187066
2026-11-14 03:40:45
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -A9 'ERROR inner_main:shutdown'
2026-11-14T03:40:30.987487Z ERROR inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:675: Multiple Errors: Unknown Error: filebrowser: Connection refused (os error 111)
2026-11-14T03:40:30.987504Z DEBUG inner_main:shutdown: start_core::error: shared-libs/crates/start-core/src/error.rs:676: Multiple Errors:
   0: Unknown Error: filebrowser: Connection refused (os error 111)
Location:
   shared-libs/crates/start-core/src/error.rs:574
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   0: start_core::context::rpc::shutdown
      at shared-libs/crates/start-core/src/context/rpc.rs:605
   1: start_core::bins::startd::inner_main
      at shared-libs/crates/start-core/src/bins/startd.rs:27
$ sudo journalctl -u startd -b -1 -o cat --no-pager | sed 's/\x1b\[[0-9;]*m//g' | grep -E 'RpcContext is shutdown|Beginning server shutdown|Beginning server restart' | cut -c1-160
2026-11-14T03:40:30.987525Z  INFO inner_main:shutdown: start_core::context::rpc: shared-libs/crates/start-core/src/context/rpc.rs:614: RpcContext is shutdown
2026-11-14T03:40:31.073126Z  INFO start_core::shutdown: shared-libs/crates/start-core/src/shutdown.rs:25: Beginning server shutdown
$ sudo start-cli diagnostic error 2>&1 | head -2
Not Found: Method not found
$ sudo start-cli git-info; systemctl is-active startd
3e0e832c3162b427450ca61999ee49f8839e8904
active

Generated with Claude Opus 5.5 in T3 Code Nightly

…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>
@dr-bonez
dr-bonez requested a review from helix-white November 17, 2026 00:34

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@helix-white

Copy link
Copy Markdown
Member

Both reviews now approve the unchanged head fc9331ee9. Substantive CI checks are now queued, including automated checks and the build matrices; their results are still pending. No code changes were requested in the approval.

@dr-bonez

Copy link
Copy Markdown
Member

@only21mil please sign all commits for any future contributions

@only21mil

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restart aborts into Diagnostic Mode when one service's teardown fails: shutdown_all error discards the pending restart (bins/startd.rs:137)

4 participants