Persist async job state to PostgreSQL so results survive API restarts #309

Closed
opened 2026-03-27 12:22:45 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Error handling and resilience

The _jobs dict lives in process memory. Any API restart (deployment, crash, OOM kill) loses all in-progress and completed job records, leaving clients with no way to retrieve results.

Work Required

  • Add a jobs table to the PostgreSQL schema (columns: job_id, status, created_at, updated_at, result_json, error)
  • Replace all reads and writes to the _jobs dict with database queries
  • Ensure job creation, status updates, and result storage are all persisted
  • Add a migration or CREATE TABLE IF NOT EXISTS statement that runs at startup

Acceptance Criteria

  • Creating a batch job and restarting the API still returns the job status and results via the /jobs/{id} endpoint
  • Job listing (/jobs) reflects all historical jobs from the database
  • No regressions in existing API tests
## Context Roadmap item: P1 Error handling and resilience The `_jobs` dict lives in process memory. Any API restart (deployment, crash, OOM kill) loses all in-progress and completed job records, leaving clients with no way to retrieve results. ## Work Required - Add a `jobs` table to the PostgreSQL schema (columns: `job_id`, `status`, `created_at`, `updated_at`, `result_json`, `error`) - Replace all reads and writes to the `_jobs` dict with database queries - Ensure job creation, status updates, and result storage are all persisted - Add a migration or `CREATE TABLE IF NOT EXISTS` statement that runs at startup ## Acceptance Criteria - Creating a batch job and restarting the API still returns the job status and results via the `/jobs/{id}` endpoint - Job listing (`/jobs`) reflects all historical jobs from the database - No regressions in existing API tests
AI-Manager added the P1agent-readymedium labels 2026-03-27 12:22:45 +00:00
Author
Owner

This issue has already been resolved in the fork's main branch. Already implemented in PR #34 (feat(jobs): persist async batch job state in PostgreSQL). See SPARC/database.py jobs table.

Closing as completed.

This issue has already been resolved in the fork's main branch. Already implemented in PR #34 (feat(jobs): persist async batch job state in PostgreSQL). See SPARC/database.py jobs table. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#309