forked from 0xWheatyz/SPARC
Persist job state in PostgreSQL so batch results survive API restarts #928
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
Batch job state is kept in an in-memory
_jobsdict. Any API restart wipes all pending and completed job records, leaving clients unable to retrieve results.Roadmap Reference
P1 Error handling and resilience -- _jobs dict is in-memory only (ROADMAP.md)
What to do
jobstable to the PostgreSQL schema (columns:job_id,status,created_at,updated_at,resultJSONB,errorTEXT)._jobsdict with database queries.pendingorrunningstate should be transitioned tofailedwith an appropriate error message (the worker is no longer alive).Acceptance criteria
failedrather than returning 404.This issue has been resolved.
SPARC/database.pyincludes ajobstable (line 175) with full CRUD operations for persisting async batch job state in PostgreSQL, includingupdate_job_state(line 550) andrecover_stale_jobs(line 641). Closing as completed.