forked from 0xWheatyz/SPARC
Persist job state in PostgreSQL so batch results survive API restarts #1269
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
The
_jobsdictionary in the API process is in-memory only. A restart (crash, deployment, OOM kill) silently discards all pending and completed job state, with no way for callers to retrieve results.Roadmap reference: P1 - Error handling and resilience
What to do
jobstable in PostgreSQL (or reuse an existing schema migration mechanism) with columns for job ID, status, created_at, updated_at, and result (JSONB)._jobswith database queries.Acceptance criteria
GET /jobs/{id}returns correct status for jobs that were created before the restart.Triage: Already Implemented
Job persistence in PostgreSQL is fully implemented on
main:SPARC/database.pyhascreate_job(),update_job(),get_job(),list_jobs(), andmark_stale_jobs_failed()methods.SPARC/api.pyuses these methods for the async batch endpoint (/analyze/batch/async), job status (/jobs/{job_id}), and job listing (/jobs) with cursor-based pagination._jobsin-memory dict is no longer used; all state is in PostgreSQL.Closing as completed.