forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL so results survive API restarts #1197
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Batch job state is currently stored in an in-memory
_jobsdict. Any API restart wipes all pending and completed job results, leaving users with no way to retrieve their analysis.Roadmap reference: ROADMAP.md > P1 > Error handling and resilience > _jobs dict is in-memory only
What to do
jobstable in PostgreSQL with columns for job ID, status, created_at, updated_at, result (JSONB), and error._jobsdict with database queries.GET /jobs/{job_id}endpoint to query the database.Acceptance criteria
GET /jobs/{job_id}returns results for jobs that completed before a restart.This issue has been resolved on main.
SPARC/database.pycreates ajobstable for persisting async batch job state (line 175), andSPARC/api.pyuses a database-backed job persistence pattern (line 904). Closing as complete.