1ccacad63281094de8a3372d5a507d38f9969e5c
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f4c664a09c |
plugin, gui: magpie web ends its plugin hosts, waited for, before it runs the new version (#3285)
The second way acezan's 57 <defunct> magpie-bun (v0.1.2819, a Linux systemd service, 47 hours) pile up: magpie web's restart to update (AutoRestart) runs the new version with syscall.Exec in the same pid. The running plugin host was the old image's child, and the old image's host.read held the only Wait for it. After the exec nothing waits for it, so it ends on stdin EOF and stays <defunct> under that pid, one per restart to update. skygunner reproduced it and AAEE86 counted 22 zombies for 23 images under one pid (#3285). With about a hundred releases a day, an AutoRestart service makes about one a hour, as acezan's did. - plugin.EndHosts (host.go) stops every host started and not yet reaped, including the retiring ones, waits until each one has been waited for, and refuses to start another (errHostsEnded). startOn starts the host and records it under one lock (live), so a host that starts during EndHosts isn't missed. - Web.Wait calls it right before update.Reexec. Run at 72bc741ef (on origin/main |
||
|
|
a9a8f11e7f |
plugin, proc: a plugin host is waited for when it ends, not when its stdout does
acezan on Discord (v0.1.2819, Linux x86_64, a systemd service): after 47 hours, 57 <defunct> magpie-bun children of magpie, growing toward the unit's TasksMax until a restart. One cause: the plugin host's only cmd.Wait ran in host.read after its stdout reached EOF. A program a plugin started that kept a copy of the host's stdout (Bun.spawn given Bun.stdout, which host.js's spawn guard doesn't catch, #5063; a daemon left behind) held that pipe open past the host's end, so EOF never came, Wait never ran, the host was never marked dead, and every host stopped (Restart, a moved proxy, hostStale) stayed a zombie until magpie quit. Reproduced on Linux (WSL magpie-desktop, Bun 1.4.2): one more Z-state bun under the test process per Restart, 1, 2, 3, 4 over four rounds. The other cause, magpie web's restart to update leaving the running host behind its exec (#3285), is the next commit. - proc.Output (new, internal/proc/output.go) gives a command's stdout and stderr pipes of magpie's own and waits for the command the moment it ends. Its readers then have OutputGrace (2s) to read the last lines; the pipes are closed after that, which ends a read held up by a grandchild. startOn uses it, and a reap goroutine fails the host when its child ends. host.read no longer calls Wait. The tests' fake hosts (no child) keep cmd.Wait. - Every other start that wasn't waited for now goes through proc.StartReaped (Start, then go cmd.Wait()). Process.Release doesn't reap on Unix: codexrelay.Start (a relay that can end while magpie runs), tui serveInBackground, uninstall's startAfter, update's runAfterExit and OpenBeside (no Wait at all), and Windows' Reexec. - TestEveryStartedCommandIsWaited (internal/proc) parses every non-test .go file. In each function, an x.Start() on a command needs an x.Wait(), or x handed on (a call's argument, a struct field), and .Process.Release() is refused. It found exactly the sites above. - docs/subsystems/provider-plugins.md says how the host is reaped. Checked and left as they are (each waits): the StartTree callers (provider/install, library mcp_run and mcp_check, gateway claude_warmup and claude_subscription), pii/serve, provider grok and claude_signin, claudetui child_unix and wslread, awake, every other bun start (bun.go, bunupdate, store, dist use Output/CombinedOutput). Run at 82460a2f9 (on origin/main |