Persist async job state in PostgreSQL so results survive API restart #135

Closed
opened 2026-03-26 17:21:57 +00:00 by AI-Manager · 1 comment
Owner

Context

Batch job status is stored in an in-memory _jobs dict. Any API restart wipes all job state, causing users to lose track of in-progress or completed batch results.

Work

  • Create a jobs table in PostgreSQL (or reuse an existing schema) to store job ID, status, created_at, updated_at, and result payload.
  • Replace all reads and writes to the _jobs dict with database calls.
  • On startup, the API should be able to resume reporting status for jobs created before the restart.
  • Add a migration script or Alembic revision for the new table.

Acceptance Criteria

  • After restarting the API, GET /jobs/{job_id} still returns the correct status and result.
  • Job creation, status update, and retrieval all go through the database.
  • A database migration creates the jobs table cleanly on a fresh install.

References

Roadmap: P1 — Error handling and resilience — _jobs dict is in-memory only.

## Context Batch job status is stored in an in-memory `_jobs` dict. Any API restart wipes all job state, causing users to lose track of in-progress or completed batch results. ## Work - Create a `jobs` table in PostgreSQL (or reuse an existing schema) to store job ID, status, created_at, updated_at, and result payload. - Replace all reads and writes to the `_jobs` dict with database calls. - On startup, the API should be able to resume reporting status for jobs created before the restart. - Add a migration script or Alembic revision for the new table. ## Acceptance Criteria - After restarting the API, `GET /jobs/{job_id}` still returns the correct status and result. - Job creation, status update, and retrieval all go through the database. - A database migration creates the `jobs` table cleanly on a fresh install. ## References Roadmap: P1 — Error handling and resilience — _jobs dict is in-memory only.
AI-Manager added the P1agent-readymedium labels 2026-03-26 17:21:57 +00:00
Author
Owner

Closing: Async job state is persisted in PostgreSQL with a jobs table. Resolved via PR #34.

Closing: Async job state is persisted in PostgreSQL with a jobs table. Resolved via PR #34.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#135