forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL so batch results survive API restarts #206
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
The
_jobsdictionary in the API is held purely in memory. Any API restart (deploy, crash, pod eviction) silently discards all in-progress and completed job results. Users have no way to retrieve results after a restart.Roadmap reference: ROADMAP.md > P1 > Error handling and resilience
What to do
jobstable in PostgreSQL (or reuse an existing migration mechanism) with columns:job_id,status,created_at,updated_at,result(JSONB),error._jobsdict with database queries./jobs/{job_id}) reads from the database.CREATE TABLE IF NOT EXISTSat startup.Acceptance criteria
/jobs/{job_id}endpoint returns404for unknown IDs rather than a KeyError 500.This issue has already been resolved in the current codebase.
database.pyhas ajobstable withcreate_job(),update_job(),get_job(),list_jobs(), andmark_stale_jobs_failed()methods. The API persists all job state to PostgreSQL, so batch results survive restarts.Closing as already implemented.