forked from 0xWheatyz/SPARC
Persist async batch job state in PostgreSQL instead of in-memory dict #738
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 reference: P1 - Error handling and resilience
The
_jobsdict in the API is in-memory only. All job state (status, results, errors) is lost whenever the API process restarts, making the batch processing feature unreliable in production.What to do
jobstable in PostgreSQL (or reuse an existing schema) with columns:id,status,created_at,updated_at,result(JSON),error_jobsdict with database queriesfailedwith an appropriate message/jobs/{job_id}and/jobsendpoints continue to work correctlyAcceptance criteria
/jobsAPI endpoints return correct data from the databasejobstable_jobsdict remainResolved. Job state is persisted in PostgreSQL via
db.create_job(),db.update_job(),db.get_job(), anddb.list_jobs(). On startup, stale jobs are marked failed viadb.mark_stale_jobs_failed(). No in-memory_jobsdict remains.