Skip to content

Pool worker should survive an early spored pool-worker exit (restart-on-exit), not run once at boot #465

Closed

Description

@scttfrdmn

Context

Pool workers (#70) run `spored pool-worker` as a one-shot cloud-init/user-data invocation. If that process exits for any reason, the worker instance keeps running (billing) but never pulls another task — it's a silent dead worker until TTL/idle-timeout reaps it.

A real-AWS re-smoke hit exactly this: the worker's `OpenQueue` raced queue creation, got `NonExistentQueue`, and the process exited at boot. That specific race is fixed in #464 (OpenQueue retries the consistency window). But the general fragility remains: any early exit — a transient AWS error the retry doesn't cover, an OOM, a panic, an idle-drain that fires before the submitter has enqueued anything — leaves a dead-but-billing worker.

Proposal

Make the on-instance worker restart-on-exit rather than fire-once:

  • Run `spored pool-worker` under a small supervisor: either a systemd unit with `Restart=on-failure`/`RestartSec`, or a bash `until` loop in the bootstrap that re-execs it (bounded, with backoff), until the instance's TTL/idle-reaper tears it down.
  • Care needed so restart-on-exit composes with the intended idle-drain: a clean idle-timeout exit should still let the instance terminate (scale-to-zero), while an error exit should restart. Distinguish via exit code (e.g. 0 = drained-clean → don't restart → let on_complete terminate; non-zero = error → restart).

Why not in #464

#464 fixes the observed failure (the consistency race) minimally. This is a broader hardening with a design choice (systemd vs loop, and the drain-vs-error exit-code contract) that deserves its own change + tests, rather than being bundled into a targeted bug fix.

Acceptance

  • A worker whose `spored pool-worker` exits with an error restarts and resumes pulling.
  • A worker that idle-drains cleanly still terminates (no busy-restart-loop defeating scale-to-zero).
  • Covered by a test of the exit-code→restart decision.

Discovered during #70 real-AWS validation.

Activity

  1. added a commit that references this issue on Jul 31, 2026
  2. added a commit that references this issue on Jul 31, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions