forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL so results survive API restarts #853
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
Roadmap item: P1 - Error handling and resilience
The
_jobsdict in the API is in-memory only. Job state (status, results, errors) is lost whenever the API process restarts, making it impossible to retrieve batch results after a restart or deployment.Work to do
jobstable in PostgreSQL (columns:id,status,created_at,updated_at,result(JSONB),error).CREATE TABLE IF NOT EXISTS) to create the table at startup._jobsin-memory dict with database queries.Acceptance criteria
GET /jobs/{job_id}endpoint returns correct data after a restart.Resolved in codebase. SPARC/database.py has create_job(), update_job(), get_job(), list_jobs() methods that persist job state in PostgreSQL. SPARC/api.py uses these for all job operations. Stale jobs are marked failed on startup. Closing as implemented.