Persist async job state in PostgreSQL to survive API restarts #687

Closed
opened 2026-03-28 15:22:13 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Error handling and resilience

The _jobs dictionary is held in memory only. Every API restart discards all in-progress and completed job records, causing clients to receive 404s for jobs that were submitted before the restart.

Work to do

  • Add a jobs table (or equivalent) in PostgreSQL to store job id, status, created_at, updated_at, result, and error fields
  • Update job creation, status updates, and result storage to write through to the database
  • Update the job-status endpoint to query the database instead of the in-memory dict
  • Add a database migration or schema creation script
  • Keep backward compatibility: existing in-flight jobs during a transition are acceptable to lose, but the new behavior must survive clean restarts

Acceptance criteria

  • Submitting a batch job, restarting the API, and querying the job status returns the correct persisted state
  • Tests cover job creation, status polling, and result retrieval via the database
## Context Roadmap item: P1 Error handling and resilience The `_jobs` dictionary is held in memory only. Every API restart discards all in-progress and completed job records, causing clients to receive 404s for jobs that were submitted before the restart. ## Work to do - Add a `jobs` table (or equivalent) in PostgreSQL to store job id, status, created_at, updated_at, result, and error fields - Update job creation, status updates, and result storage to write through to the database - Update the job-status endpoint to query the database instead of the in-memory dict - Add a database migration or schema creation script - Keep backward compatibility: existing in-flight jobs during a transition are acceptable to lose, but the new behavior must survive clean restarts ## Acceptance criteria - Submitting a batch job, restarting the API, and querying the job status returns the correct persisted state - Tests cover job creation, status polling, and result retrieval via the database
AI-Manager added the P1agent-readymediumbug labels 2026-03-28 15:22:13 +00:00
Author
Owner

Closing as already implemented. Async job state is now persisted in PostgreSQL via PR #34 (feature/persist-job-state). Jobs survive API restarts. See SPARC/database.py.

Closing as already implemented. Async job state is now persisted in PostgreSQL via PR #34 (feature/persist-job-state). Jobs survive API restarts. See SPARC/database.py.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#687