forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL to survive API restarts #1424
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?
Summary
The
_jobsdict in the API is in-memory only. All in-flight and completed job statuses are lost when the API process restarts, making batch jobs unreliable.What to do
jobstable to the PostgreSQL schema (columns:id,status,created_at,updated_at,result_json,error)._jobsdict with database queries.Acceptance criteria
GET /jobs/{id}returns correct status for a job created before the restart.References
Roadmap: P1 Error handling -- persist job state.
Already implemented.
SPARC/database.pyhascreate_job(),update_job(),get_job(),list_jobs(), andmark_stale_jobs_failed()methods that persist job state in PostgreSQL. The API lifespan hook marks stale jobs as failed on startup. All job endpoints inSPARC/api.pyuse the database for persistence.Closing as completed.