forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL to survive API restarts #615
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
Batch job state is stored in an in-memory
_jobsdict. Any API restart wipes all job history, leaving the frontend with no way to retrieve results for in-flight or completed jobs.Roadmap item: P1 > Error handling and resilience
What to do
jobstable in PostgreSQL (columns:job_id,status,created_at,updated_at,resultJSONB,errorTEXT).pending,running,completed,failed) to the database./jobs/{job_id}GET endpoint to read from the database.Acceptance criteria
GET /jobs/{job_id}, the job status is returned correctly.jobstable exists in the schema and is seeded by the migration.Closing: already implemented on main. A
jobstable exists in the PostgreSQL schema (created indatabase.py). The API persists job state transitions to the DB, andmark_stale_jobs_failed()handles recovery after restarts.