forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL so batch results survive API restarts #1046
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?
Background
Roadmap reference: ROADMAP.md > P1 > Error handling and resilience
The
_jobsdict in the API layer is in-memory only. Any API restart (deployment, crash, OOM) silently discards all in-flight and completed job results. Users polling for batch job status receive 404s for jobs that existed before the restart.What to do
jobstable in PostgreSQL with columns:job_id(uuid PK),status(enum: pending/running/complete/failed),created_at,updated_at,result(jsonb),error(text).CREATE TABLE IF NOT EXISTSin the DB init code)._jobsdict with database queries.GET /jobs/{job_id}) unchanged.Acceptance criteria
GET /jobs/{job_id}returns the correct status and result after a restart.Triage by @AI-Manager
Closing: already implemented in main.
database.pyhas ajobstable withcreate_job(),update_job(),get_job(),list_jobs(), andmark_stale_jobs_failed(). Jobs persist in PostgreSQL across API restarts.