Skip to content

Reconcile nonterminal deployments after job retries are exhausted #486

Done

Description

@samuelmbabhazi

Problem and impact

An active deployment can lose its only runnable job after deployment-run exhausts its finite retry budget. Restoring the failed infrastructure dependency does not, by itself, wake that deployment. It can remain nonterminal and retain the application's single active deployment slot until an operator cancels or repairs it.

Affected revision: 1295e534d7a1c3cd0a492449de8806aa532a4924. Priority: P1, durable deployment recovery.

Scenario and evidence

  1. A deployment and its first queue job commit successfully. The existing transactional enqueue is a useful guarantee and should be retained.
  2. Before any agent action has been enqueued, pipeline processing repeatedly fails because an infrastructure operation cannot complete. For example, an application-side transaction timeout can fail the pipeline while pg-boss can still record the job failure.
  3. deployment-run has retryLimit: 5. After the retries are exhausted, pg-boss leaves that job failed rather than continuing to poll the deployment.
  4. The underlying problem is corrected, but no agent action exists whose completion could wake this deployment.

The worker schedules its 15-second recheck only after pipeline.run() returns wait; an exception is rethrown for pg-boss to retry. Startup registers the queue worker, without scanning unfinished deployments. The event-based waker handles terminal agent-action events. No independent startup/periodic reconciliation or exhausted-job handoff was found for active deployments.

The deployment still counts as active, and the partial unique index correctly prevents a second active deployment. A failed queue job consequently becomes a lasting application-level availability problem.

Evidence level: source control-flow review and the installed pg-boss retry/failure semantics. No PostgreSQL fault-injection or retry-exhaustion integration test was executed during this audit. A complete PostgreSQL outage is not assumed to consume retries: pg-boss must still be able to persist the failed attempts for this scenario.

Relationship to closed #314

#314 addressed invalid/unplannable releases throwing from planning or placement. Those fixes are present: planning and placement convert domain errors into a failed deployment. This follow-up concerns unexpected infrastructure failures and the missing recovery path once the queue's retry budget is exhausted. It does not reopen the invalid-configuration cases or suggest retrying them indefinitely.

Proposed correction

Add bounded durable reconciliation of unfinished deployments against runnable jobs, or an explicit exhausted-job recovery mechanism with persisted status and operator visibility. Reuse tenant boundaries, singleton enqueue and action idempotency. Do not blindly mark a deployment failed if external actions may already have run; recovery must account for their observed/uncertain state.

Acceptance criteria

  • Inject an infrastructure failure before the first agent action until the job exhausts its retry budget. Restore the dependency and verify deterministic recovery, or a visible, actionable recovery state with a supported retry operation.
  • Cover control-plane restart after exhaustion and concurrent reconciliation with an existing job; do not create duplicate agent side effects.
  • Verify the active deployment slot is not silently stranded indefinitely.
  • Retain readable terminal failure for invalid plans and placements covered by A deployment whose plan throws stays stuck instead of failing #314.
  • Add a case with an already-issued agent action so recovery preserves routing and idempotency under uncertain outcomes.

Publication check (2026-11-25): main advanced to 2ee78ff1e96118b1732b98bc54c99f5f91b95a32 through #469, which changes only an exec-session test. The production paths above are unchanged.

Activity

  1. added
    bug
    priority:P1
    v0.1-stable
    on Nov 25, 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

    bugpriority:P1track:control-planev0.1-stable

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions