Skip to content

A daemon stop cancels the Android seed the warm pool is making #1964

Done
1 of 1 issue completed
Done

Description

@V3RON

Request: #1700

Problem

simlock daemon stop waits for every device the warm pool is creating. Making an Android seed takes minutes: 331 s with its copy on the Windows PC in #1700. daemon stop gives up after 300 s, so it fails with SERVICE_FAILED while the daemon and the seed's emulator run on. A service manager gives up after 300 s too and kills the daemon, leaving the emulator behind.

Who it is for

The operator of a worker, or the update and service tools that stop it, when the warm pool is filling after a fresh install, an SDK update or a settings change.

Outcome

A stop cancels a seed the warm pool is making, stops its emulator and goes on. A request still in the queue ends with the daemon, as other queued requests do. The next start makes the seed again.

How it works for the user

flowchart TD
  A[The warm pool makes an Android seed] --> B[simlock daemon stop]
  B --> C{Does a lease request's own creation or a seed settle wait for the same seed?}
  C -- no --> D[The make is cancelled, its emulator stopped, its folder removed]
  C -- yes --> E[The make finishes, the stop waits for it, as today]
  D --> F[The daemon stops]
  E --> F
  D --> G{Folder could not be removed}
  G -- yes --> H[Warning in daemon.log, the next start removes it]
  H --> F
Loading

Before:

$ simlock daemon stop
{"error":{"code":"SERVICE_FAILED","message":"The running daemon did not stop within 300 s."}}

After, the command prints what a normal stop prints, and daemon.log has:

{"level":"info","module":"daemon.warm-pool","message":"warm pool creation of a device was cancelled by the stop","fields":{"model":"Pixel 9","platform":"android"}}

Examples

What the pool is doing when the stop comes Today After
making an Android seed nobody else waits for stop waits for make, copy and boot make cancelled, no copy, no boot
making an Android seed for a lease request still in the queue, or for a target such a request hopes to take from stop waits, the request may then get the device make cancelled, the request ends with the daemon
making an Android seed a lease request's own creation waits for stop waits stop waits for the make, the request gets its device; the pool takes no copy
making an Android seed simlock was asked to settle stop waits stop waits, as today
waiting for a lease request's make of the same seed stop waits for the make, then the pool copies and boots stop waits for the make; the pool takes no copy
copying a finished seed, or booting the copy stop waits unchanged
creating an iOS simulator stop waits unchanged
a lease request making its own seed stop waits unchanged

What could go wrong

  • A lease request that already runs its own creation could be cut off or made to start over. Unlikely: the make is cancelled only when no such creation waits for it.
  • A lease request still in the queue gets no device when its make is cancelled. Certain, and chosen: it ends with the daemon and its caller asks again.
  • An emulator could outlive the cancelled make. Unlikely: it is killed and its exit waited for before the folder goes.
  • A learned device kind could be forgotten because a cancel counted as a failure. Unlikely: a cancel is not counted.

Words used

  • warm pool: the idle devices Simlock keeps booted ahead of requests, e.g. one ready Pixel 9.
  • seed: the prepared device every device of one kind is copied from, e.g. the Pixel 9 / API 35 seed. Making one boots an emulator twice.
  • make: creating a seed, from its empty folder to its saved boot snapshot.
  • waiting caller: a lease request's creation or a seed settle that asked for the same kind's seed while the pool makes it. The pool's own second creation of the kind is not one, and neither is a request still in the queue.
  • queued request: a lease request that has started no creation of its own, e.g. the second simlock lease in line while the first one's device boots.

Non-goals

  • Cancelling a make a lease request's own creation started, or waits for (maintainer, 2026-11-19).
  • Keeping the pool's make for a request still in the queue (maintainer, 2026-11-30).
  • Cancelling an operator's seed settle while it makes the seed.
  • Cancelling iOS creations, the copy of a finished seed, or a device's boot.
  • Changing the 300 s limit.
  • Cancelling on anything but a daemon stop (nuke and memory pressure stay as today).

Completion conditions

  • A daemon stop sent while the warm pool makes an Android seed nobody else waits for ends without the make finishing, and no emulator of that seed runs after it.
  • The same daemon started again makes the seed and fills its target.
  • A lease request whose own creation waits for the pool's make still gets its device's creation finished, as today.

Open questions

none

Decisions

No ADR: one driver option and one rule of the warm-pool manual change.

  • Maintainer, 2026-11-19 (Windows: daemon stop times out after 300 s while the warm pool remakes an Android seed (EBUSY on cache.img) #1700): a stop cancels a warm-pool seed make and stops its emulator; a lease request's own seed make is unchanged; the EBUSY cleanup shipped as Windows: a failed Android seed make's cleanup throws EBUSY and hides the make's error #1765.
  • Maintainer, 2026-11-30: a make the pool runs for a queued request, or that a queued request waits for, is cancelled too; the request ends with the daemon.
  • Decided in the session: a make that a lease request's own creation or a seed settle waits for is not cancelled, because the request would then make the seed from the beginning and hold the stop longer than today.
  • Decided in the session: Android only, because the fault and the decision are about the Android seed make; iOS ignores the signal.
  • Decided in the session: the pool cancels when it drains, and from just before that the stop lets no request start a creation or an eviction. A cancelled make frees its slot, and any other flight, grant or failure that ends during the drain wakes the queue, so without this a queued request could start its own make in front of the stop. A request may still be granted a ready device or boot a shut-down one, as today. A lease request whose own creation fails from then on is not tried a second time before the daemon ends; one under way is never cut.
  • Decided in the session: a cancel is logged at info, is no failure and does not wake the queue, as an aborted seed settle is no failure.
  • Decided in the session: copy and boot of a finished seed are not cancelled, because the decision covers the make, and cutting a copy or a boot needs its own cleanup.

Behaviours

Id Behaviour (invoker, action, what it sees) Seam Cases Task
B1 An operator stops the daemon while a warm target's creation is inside the driver's provision and the driver honours the signal: the stop ends without the creation finishing, no device record is written, the log holds the I4 line and no warm pool creation of a device failed startDaemon with a FakeDriver that holds provision until aborted stop by daemon.stop() #1968
B2 An operator stops the daemon while a learned kind that already failed twice is being created: the cancel is not a third failure, so the kind is still learned after it WarmPool.drain (the pool harness) — #1968
B3 A stop cancels a pool creation while a request waits in the queue for the slot it held: the stop starts no creation for that request and ends without one startDaemon with fake Android and iOS drivers Android limit 1, one target creation under way, one queued Android request: of another model; of the same model. The same with a second flight, an iOS creation that ignores the signal and ends after the cancel (its end wakes the queue). In each, the Android provision is called once and no lease is granted #1968
B4 A stop comes when the pool's creation has not reached the driver: the provisioner is never called and the reservation is given back WarmPool.drain (the pool harness) the flight waits for its reservation's turn in the decision lock when the drain begins #1968
B5 A stop comes while a creation's driver ignores the signal, or while a registered device boots: the stop waits and the device ends ready; the pool starts nothing else core.drain through createLeasing booting: proved by the existing test "on a graceful drain finishes the creation in flight"; driver ignores the signal: new #1968
B6 A caller aborts AndroidDriver.provision while it makes the seed: it rejects with the signal's reason, after the seed's emulator was killed and has exited, the folder and the making row are gone, and the console port is free; no adb, emulator or avdmanager command starts after it rejects AndroidDriver.provision with scripted processes aborted during: avdmanager create; the first boot's wait for the device; sync; the wait for power-off; the second boot's wait; the snapshot save; the wait for the emulator's exit after the save #1968
B7 As B6, when the folder cannot be removed: it still rejects with the signal's reason, the existing warning is logged and the making row stays AndroidDriver.provision with scripted processes removal throws EBUSY #1968
B8 A caller aborts while another call waits for the same seed: a call with no signal keeps the make running, its result is used, and the aborted call then rejects with the signal's reason and takes no copy AndroidDriver with scripted processes waiting provision with no signal: make finishes; waiting ensureSeed: make finishes; waiting provision with the same aborted signal: make cancelled, both reject, one make only; provision with no signal that arrives after the abort: waits for the cleanup, then makes its own seed #1968
B9 A caller's signal is aborted before any make of its own runs: provision rejects with the signal's reason and makes and copies nothing AndroidDriver.provision with scripted processes aborted before the call; aborted while it waits for the lock of a make another call runs (that make finishes) #1968
B10 A caller aborts after the copy of the finished seed began: the copy ends and the device is returned AndroidDriver.provision with scripted processes abort during the copy #1968
B11 During the drain a request in the queue is planned: it gets a ready device or boots a shut-down one as today, and it starts no creation and no eviction; the reservation or claim its plan took is given back createLeasing plan is a grant of a ready device; a boot of a shut-down one; a creation; an eviction of an idle device (nothing is shut down or deleted); a creation already under way when planning closes: it ends in a grant #1968

Stored state

Id What and where Created, changed, deleted by Listed or swept by A restart mid-step leaves Schema step Task Used by
S1 a cancelled make's making row in the Android sources table, its folder under sources/ and its emulator process the make as today; a cancel kills the emulator, waits for its exit, removes the folder, then the row; a removal that fails leaves the row #sweepLeftovers at the next listing (startup's first listSources) or make of the kind, as today row, folder and maybe the emulator; the sweep stops the emulator by path, then deletes folder and row, as today none #1968 —

Interfaces

Id What Shape and bounds Errors and limits Where Task Used by
I1 Driver.provision option provision(spec, options?: { source?: string; signal?: AbortSignal }); a driver may ignore signal. Android reads it as B6 to B10; with source it has no make to cancel and ignores it. iOS ignores it. FakeDriver honours it while a test holds the call rejects with signal.reason when it cancels src/core/driver.ts, both drivers, src/core/fake-driver.ts #1968 —
I2 ProvisionDeviceOptions.signal optional AbortSignal, passed to driver.provision unchanged; a rejection takes today's path (component claim, baseline hold and reservation released). Leasing passes none the driver's rejection, unchanged src/core/device-provisioner.ts #1968 —
I3 the warm pool's drain one AbortController per WarmPool, aborted once in drain(), not in close(); every #provision passes its signal, whatever its reason (a target, a learned kind or a waiting request); one that gets its reservation after the abort releases it and ends as declined. A rejection with the signal's own reason (the same object) logs I4, and calls neither #failed nor kick; any other rejection takes today's path, aborted or not — src/core/warm-pool/converger.ts #1968 —
I4 log line of a cancelled creation info, message warm pool creation of a device was cancelled by the stop, fields model, platform — src/core/warm-pool/converger.ts #1968 —
I7 Leasing.stopCreations() (): void; sets a flag on AcquisitionGates that nothing clears. With it set, decide releases the resources of a plan of kind provision, evict-running or evict-managed (releasePlanResources) and answers undefined, before markProcessing, as it does after stopPlanningForGood. The worker's stop calls it after leasing.settle() and before core.drain() none src/leasing/acquisition-gates.ts, src/leasing/acquisition-workflow.ts, src/leasing/lease-acquisition-coordinator.ts, src/leasing/create-leasing.ts, src/daemon/worker-composition.ts #1968 —
I5 the Android make's cancel Seeds counts, per spec key, the callers with no signal that are waiting for or holding the kind's lock, from before they queue for the lock until they leave it. The make runs on its own controller, aborted when its maker's signal aborts and that count is 0 at that moment; a count that drops later aborts nothing. After it gets the lock, and again before it copies, a caller with an aborted signal rejects. The make's abort kills the emulator handle in hand, so each wait on it ends, and every step checks the abort before the next one starts; a make that reached ready stays the make's own error is replaced by the signal's reason only when its controller is aborted; the kill's exit wait is SIGKILL_REAP_TIMEOUT_MS, as today src/drivers/android/seeds.ts #1968 —
I6 Emulator.start, waitForReadiness and AdbTools.runOrThrow with an optional signal start checks it after the crash-report flag probe and before the spawn; on abort it kills the emulator, waits for its exit, and waits for the readiness loop to end before it throws, so no probe runs later. Commands of the make get the signal through the process runner, which ends the child (endedBy: "aborted"); the readiness loop starts no probe after an abort. The scripted runner's hanging call must end on the signal too throws signal.reason; calls without a signal are as today src/drivers/android/emulator.ts, src/drivers/android/adb-tools.ts, src/ports/scripted-process-runner.ts #1968 —

Existing code

Commit fd7a19c.

Searches: rg '\.provision\(|ensureSeed\(' in src/ outside tests (5 callers: device-provisioner, leasing's workflow, both drivers' index.ts, the settler through ensureSeed?.); rg 'drain\(\)|closeWarmPool|stopPlanning' (core, daemon, leasing); rg 'AbortSignal|signal' in src/core and src/drivers/android; rg 'emulator\.(start|shutdown)' in src/drivers/android.

Id Code (path:line) Today With this feature Handled by
X1 src/core/warm-pool/converger.ts:357 drain closes, then waits for the pass and every flight aborts the pool's signal before it waits; still waits for every flight's end B1, I3
X2 src/core/warm-pool/converger.ts:855 #provision a failure warns, counts and kicks the queue a cancel does none of the three B1, B2, B3, B4, I3, I4
X3 src/core/device-provisioner.ts:139 passes source only passes signal too I2
X4 src/leasing/acquisition-workflow.ts:259 a lease request's creation passes no signal, so nothing cancels it B8, I2
X5 src/daemon/worker-composition.ts:617 core.drain() after leasing.settle(), before the drivers are disposed leasing.stopCreations() runs between the two; the abort comes in the drain B1, B3, I7
X6 src/daemon/worker-composition.ts:632 settleAcquisitions planning stops only here, after the drain creations and evictions stop being planned before the drain; the rest of planning stops here, as today B3, B11, I7
X7 src/core/seed-settle/settler.ts:488 #ensure ensureSeed joins or makes the seed; the settler's stop waits for it counts as a waiting caller B8
X8 src/drivers/android/seeds.ts:697 #freshSeed one make per kind under a lock; a waiting caller copies the made seed counts waiting callers and checks the signal under the lock B8, B9, I5
X9 src/drivers/android/seeds.ts:680 #copyFreshSeed copies once the seed is ready checks the signal before the copy, not during it B8, B10
X10 src/drivers/android/seeds.ts:828 #makeSeed a failed make removes folder and row (:898) and throws its error the same cleanup, then the signal's reason when cancelled B6, B7, I5
X11 src/drivers/android/seeds.ts:905 #bootSeedTwice kills the emulator and waits for its exit in finally an abort kills it at once, so the waits inside end B6, I5
X12 src/drivers/android/emulator.ts:318 start a failed start kills the emulator; a probe of the abandoned readiness loop may still run on an abort the loop's end is awaited: an adb command after the adb server stopped would start a server on its port (#1200) B6, I6
X13 src/drivers/android/emulator.ts:350 shutdown waits for the handle to exit, up to EMULATOR_EXIT_TIMEOUT_MS unchanged; the kill of X11 ends its wait B6
X14 src/drivers/android/seeds.ts:203 #sweepLeftovers removes a making row this process is not making unchanged; clears what B7 leaves S1
X15 src/cli/daemon-service.ts:5 the CLI waits 300 s unchanged —
X16 src/core/fake-driver.ts:498 provision takes source only honours signal while held I1
X17 src/ports/node-process-runner.ts:557 run's signal kills the child, endedBy: "aborted" unchanged, used by I6 I6
X18 src/core/warm-pool/policy.ts:405 createForWaiter the pool creates a device for a queued request that is not the head; #act runs it through #provision cancelled like a target's creation; the request stays queued until the daemon ends B3, I3
X19 src/core/warm-pool/AGENTS.md:26, docs/internal/flows/startup.md:134 , src/leasing/AGENTS.md:48 and website/src/content/docs/docs/worker/daemon.mdx:39 "drain() finishes the pass and running boots", "core drains the warm pool", "settleAcquisitions() stops planning for good" the first two say the drain cancels a creation still inside the driver; the last two say stopCreations() runs before the drain and what it stops; the website page says which work a stop finishes and that it cancels a seed the warm pool is making #1968
X20 src/leasing/acquisition-workflow.ts:295 decide and :685 wakeQueue only stopPlanning refuses a plan; any wake drives the head a wake still drives the head; decide refuses creations and evictions after stopCreations() B3, B11, I7

Tasks

Completion conditions: all by #1968.

Open work in the same area: PR #1927 (dotted API images) changes src/drivers/android/seeds.ts; it is no task, so there is no Depends on, and the branch that merges second rebases. #1956, #1957 and #1962 merged after the commit this was read at; they change an error text and the physical phones' tags only. #1920 / PR #1958 (conhost stdin) touches the process runner only.

Written by an agent.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    feature:spec
    on Nov 30, 2026
  2. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Design posted: all sections, from the triage report of #1700 and the maintainer decisions of 2026-11-19.

    Written by an agent.

  3. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Spec updated: the maintainer decided (2026-11-30, asked in the session) that a stop also cancels a make the pool runs for a request still in the queue. Changed: How it works, Outcome, Examples, What could go wrong, Words used, Non-goals, Completion conditions, Decisions, B3, B4, I3, X18 (new), X19 (was X18).

    Written by an agent.

  4. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Spec updated: from just before the drain a stop starts no new creation or eviction for a request, so a cancelled make cannot be started again by a queued one (checker finding). Changed: Decisions, B3, B11 (new), I7 (new), X5, X6, X19, X20 (new).

    Written by an agent.

  5. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    #1964 A daemon stop cancels the Android seed the warm pool is making: #1964

    ADR: none.

    Maintainer, 2026-11-30: a make the pool runs for a request still in the queue, or that such a request waits for, is cancelled too.

    Decided in the session:

    • a make that a lease request's own creation or an operator's seed settle waits for is not cancelled
    • Android only; iOS ignores the signal
    • the pool cancels when it drains, late in the stop. Just before that, no request may start a creation or an eviction any more. A lease request whose own creation fails from then on is not tried a second time; one under way is never cut
    • a cancel is logged at info, is no failure and does not wake the queue
    • the copy and the boot of a finished seed are not cancelled
    Task What it delivers Rows Depends on
    T1 daemon stop cancels an Android seed the warm pool is making B1 to B11, S1, I1 to I7, X1 to X20 —

    Check: ready

    Written by an agent.

  6. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Spec updated: the design is approved by the maintainer (2026-11-30); the task is #1968, and the open work names what merged since.

    Written by an agent.

  7. added
    feature:planned
    and removed
    feature:spec
    on Nov 30, 2026
  8. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor
    Task What it delivers Depends on
    #1968 daemon stop cancels an Android seed the warm pool is making —

    chain 1 of 1 tasks

    Decisions since the design was settled: none. Three notes of the task check are folded in: X19 names the website page worker/daemon.mdx; the task names that page and the lease model's stop, and no longer the Android manual.

    Written by an agent.

  9. added
    platform:android
    on Nov 30, 2026
  10. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1968 — review round 1 is incomplete (claims lens left one test file unread); 7 blocking findings open on PR #1970
    Waiting: none
    Decided: #1968 — is the end of a no-signal call pinned (B8)? → add a case, #1968 — abort checks no test makes fail (B6)? → keep those I5/I6 name, remove the redundant rest, #1968 — is "the cancel wakes no queue" pinned (I3)? → assert it in the pool harness

    Written by an agent.

  11. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1968 — one blocking finding (R5) open on PR #1970 after the last allowed fix-check
    Waiting: none
    Decided: #1968 — fix only the complete round 1's findings, or the incomplete run's too? → both
    Asleep: 24 min

    Written by an agent.

  12. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1968 — R6 and R7 open on PR #1970 after the fix-check the maintainer allowed
    Waiting: none
    Asleep: 24 min

    Written by an agent.

  13. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1968 — R8 open on PR #1970 (settle scope, maintainer's call), and the last fix-check ran no lens
    Waiting: none
    Asleep: 24 min

    Written by an agent.

  14. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1968 — R9 (two comment sentences) open on PR #1970 after the last check
    Waiting: none
    Decided: #1968 — pass a settle's signal to its port reservation and shutdown (R8)? → no, out of scope
    Asleep: 24 min

    Written by an agent.

  15. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1968 — R10 (slow-lane test helper) open on PR #1970 after the last check; the lane has not run the case yet
    Waiting: none
    Asleep: 24 min

    Written by an agent.

  16. github-actions commented on Nov 30, 2026

    @github-actions
    Contributor

    Closing: all 1 sub-issues are closed. The PR that closed the last one walks the completion conditions (delivery rule 9); reopen this if one does not hold on main. Flip its ADRs to Accepted if delivery has not.

  17. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1970 (#1968)
    Parked: none
    Waiting: none
    Decided: #1968 — pin the end of a no-signal call (B8)? → yes, a case, #1968 — abort checks no test makes fail (B6)? → keep those I5/I6 name, remove the rest, #1968 — pin "the cancel wakes no queue" (I3)? → yes, #1968 — pass a settle's signal to its port reservation and shutdown (R8)? → no, out of scope
    Asleep: 24 min

    Written by an agent.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:plannedplatform:android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions