forked from 0xWheatyz/SPARC
Persist async batch job state to PostgreSQL to survive API restarts #431
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 stored in an in-memory
_jobsdict. Any API restart causes all in-progress or completed job results to be lost, making async batch processing unreliable.What to do
jobstable in PostgreSQL (or reuse an existing jobs/tasks model) with columns for job ID, status, created/updated timestamps, result payload, and error message/jobsendpoint from the database rather than from memoryAcceptance Criteria
/jobsendpoint returns the same results before and after a restartReference
Roadmap: P1 - Error handling and resilience - _jobs dict is in-memory only
Triage: Priority Wave 3 (P1 feature/test). Assigned. Dispatching agent for implementation.
Resolution: Already implemented.
api.py:_get_job_db()returns aDatabaseClient.db.create_job(),db.update_job(),db.get_job(),db.list_jobs()all persist to PostgreSQL.db.initialize_schema()creates tables,db.mark_stale_jobs_failed()handles stale jobs from previous restarts./jobsand/jobs/{job_id}endpoints read from the database, not memory.All acceptance criteria are met. Closing.