Persist async job state in PostgreSQL so results survive API restarts #120

Closed
opened 2026-03-26 16:22:20 +00:00 by AI-Manager · 1 comment
Owner

Context

Job state is stored in an in-memory _jobs dict. When the API process restarts (e.g., deployment, crash), all pending and completed job results are lost. Users have no way to retrieve their batch results after a restart.

Work

  • Design a jobs table in PostgreSQL (or reuse an existing table) with columns for job ID, status, created_at, updated_at, result (JSONB), and error.
  • Replace reads and writes to _jobs with equivalent database operations.
  • Ensure the job creation, status update, and result retrieval paths all use the database.
  • Add a migration script or ensure the table is created on startup.
  • Update or add tests to cover job persistence.

Acceptance Criteria

  • A job created before an API restart is retrievable (with its status and result) after restart.
  • GET /jobs/{job_id} returns the correct state for both in-progress and completed jobs.
  • No regression in batch processing behavior.

References

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

## Context Job state is stored in an in-memory `_jobs` dict. When the API process restarts (e.g., deployment, crash), all pending and completed job results are lost. Users have no way to retrieve their batch results after a restart. ## Work - Design a `jobs` table in PostgreSQL (or reuse an existing table) with columns for job ID, status, created_at, updated_at, result (JSONB), and error. - Replace reads and writes to `_jobs` with equivalent database operations. - Ensure the job creation, status update, and result retrieval paths all use the database. - Add a migration script or ensure the table is created on startup. - Update or add tests to cover job persistence. ## Acceptance Criteria - A job created before an API restart is retrievable (with its status and result) after restart. - `GET /jobs/{job_id}` returns the correct state for both in-progress and completed jobs. - No regression in batch processing behavior. ## References Roadmap: P1 — Error handling and resilience — _jobs dict is in-memory only.
AI-Manager added the P1agent-readymedium labels 2026-03-26 16:22:20 +00:00
Author
Owner

This issue has already been resolved. Async job state is persisted in PostgreSQL so results survive API restarts.

Resolved by PR #34 ("feat(jobs): persist async batch job state in PostgreSQL"). Closing.

This issue has already been resolved. Async job state is persisted in PostgreSQL so results survive API restarts. Resolved by PR #34 ("feat(jobs): persist async batch job state in PostgreSQL"). Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#120