Skip to content

fix(api): a transient database error no longer fails work for good (#436) - #502

Open
mblaauw wants to merge 1 commit into
mainfrom
fix/436-transient-db-errors
Open

mblaauw wants to merge 1 commit into
mainfrom
fix/436-transient-db-errors

Conversation

@mblaauw

@mblaauw mblaauw commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #436.

Summary

Three paths treated any error, including a pool timeout or a dropped
connection, as permanent.

  • Claim: a storage error while building the execution context now hands the
    execution back to the queue (new Store::release_claimed_execution, only
    for the claiming worker's still-dispatched row) instead of failing it as
    invalid_config. ApiError carries a non-serialized transient flag, set
    from the new StoreError::is_transient (pool timeout/closed, I/O, TLS,
    protocol, SQLSTATE 08/40/53/57P). Subagent lookups map only NotFound to
    "no longer exists".
  • Runtime tick: only a missing agent halts a 24/7 runtime; other lookup
    errors, an unreadable last execution and a transient access check are
    retried with backoff. Bookkeeping writes that were dropped with let _ are
    logged at warn.
  • GET /worker/env (and team env mappings in the context) answer with an
    error instead of a shorter list: storage errors pass through so the worker
    retries, and a mapping whose connection, credential or secret is gone is a
    409 naming the variable, so the run fails instead of starting without it.

Testing

  • cargo fmt --check, clippy --workspace --all-targets -D warnings: clean
  • cargo test --workspace with a database: passed; dispatcher::tests::team_lock_is_released_when_the_holder_panics failed once in one run and passed 3/3 alone and in the next full run (flaky, unrelated)
  • New tests: StoreError::is_transient (3), ApiError transient flag (2), store a_released_claim_is_queued_and_claimable_again, API worker_env_refuses_a_mapping_it_cannot_resolve (409 naming the variable, no value leak)
  • team_env_mappings_are_checked_for_the_run_principal now creates the secret it maps (it relied on a missing secret being skipped)
  • pnpm docs:check: passed

The claim and runtime-tick paths are not exercised against a failing database; the pieces (classification, release, flag) are tested. /worker/env can now return 409, which the OpenAPI document does not list yet. The team-queue claim path may have the same pattern and was not changed.

🤖 Generated with Claude Code

)

Three paths treated any error, including a pool timeout or a dropped
connection, as permanent.

- Claim: a storage error while building the execution context now hands the
  execution back to the queue (new `Store::release_claimed_execution`, only
  for the claiming worker's still-dispatched row) instead of failing it as
  `invalid_config`. `ApiError` carries a non-serialized `transient` flag, set
  from the new `StoreError::is_transient` (pool timeout/closed, I/O, TLS,
  protocol, SQLSTATE 08/40/53/57P). Subagent lookups map only NotFound to
  "no longer exists".
- Runtime tick: only a missing agent halts a 24/7 runtime; other lookup
  errors, an unreadable last execution and a transient access check are
  retried with backoff. Bookkeeping writes that were dropped with `let _` are
  logged at warn.
- `GET /worker/env` (and team env mappings in the context) answer with an
  error instead of a shorter list: storage errors pass through so the worker
  retries, and a mapping whose connection, credential or secret is gone is a
  409 naming the variable, so the run fails instead of starting without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant