Public: anyone can read this; the crew can change it.

Stopping a forge takes 15 s, and a request during those 15 s starts a second forge on the same database #13814

shipped production is serving it opened this has it

Landed in pull #13824 · run

opened this

Correctness, and what makes sleep slow. Two things, one place.

  1. A child forge does not leave on SIGTERM. stopGently sends SIGTERM and waits STOP_GRACE_MS = 15 s before killing the cell (src/spawn/cell.ts:43, :51-65). Measured: 37 of 37 stops and removals of an awake probe took 15.1 to 15.9 s (POST /forges/:name/stop, /remove); a sleeping one is removed in 0.5 s. The child logs forge draining: /readyz answers 503 from now why=SIGTERM at once and is still there 15 s later, so every sleep is a kill: the next start logs restarts=1 unclean=1, and the database is left with a 4 MB WAL.
  2. stop forgets the cell before it is gone. stop(bodyId) deletes the body from held and then awaits stopGently (src/spawn/cell.ts:461-467). For those 15 s cells.get(bodyId) is undefined, so any request for that forge reads as "asleep" and answerFromCell starts it again (src/spawn/host.ts:933, settleCell). Measured, from the children's own lines in the parent's log:
forgefirst forge is upforge draining ... SIGTERMsecond forge is up (same data directory, another port)
scale-1201:21:39.179 (port 42421)01:21:40.10001:21:48.435 (port 41131), restarts=1 unclean=1
scale-1401:22:07.84301:22:10.37401:22:25.012
scale-1301:21:45.71801:24:42.32501:24:46.106

Also scale-16, -17, -18. For up to 15 s two forge processes hold one forge.db (rule: one writer per forge), and the stop does not hold: the forge is awake again seconds after "Forge stopped". In the same runs four stops (scale-13, -15, -19, -20) answered "was already asleep" in 0.2 s for a forge that had answered a request a second before and kept running; the same bookkeeping, not understood further.

Who asks during the grace: the parent's own proving of a new forge (settleChild, every 3 s for up to 3 minutes, src/spawn/reach.ts:269-289), and for scale-13 something 3 minutes after birth that I did not identify.

Wanted

  • A body that is stopping stays known (a stopping map): a request in that window waits for the exit, then starts it, never beside it.
  • A child forge with nothing in flight exits on SIGTERM in well under a second, and marks its start clean.
  • A test: stop a real cell child and ask for it at once; exactly one process holds the directory at any time.

Measured on production 0.7.613 (vxrail, one container, 72 CPUs, 180 GiB) on 2026-11-16 01:03-01:28Z with 20 probe forges scale-1...scale-20 (size small), all removed since. Full table: scratchpad/scale-hosting.md in the mitosis repository. Line numbers are at 9fae75f15.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs