forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL so it survives API restarts #1098
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
Job state is currently stored in an in-memory
_jobsdict. When the API process restarts (deploy, crash, OOM kill), all in-flight and completed job records are lost. Users have no way to retrieve results from jobs that finished before a restart.What to do
jobstable in PostgreSQL with columns:id(UUID PK),status,created_at,updated_at,result(JSONB),error(text)._jobsin the API with DB queries.runningtofailedwith aninterruptederror message (they cannot be resumed).Acceptance criteria
jobstable.GET /jobs/{job_id}returns the correct status after an API restart (test with a completed job).runningat startup are markedfailed.Roadmap reference: P1 - Error handling and resilience
This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. Closing as completed.