forked from 0xWheatyz/SPARC
Persist async job state to PostgreSQL so jobs survive API restarts #151
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
_jobsdict in the API is an in-memory store. Any API restart (deployment, crash, OOM kill) wipes all in-flight and completed job state, leaving users with no way to retrieve their results.Work
jobstable in PostgreSQL (columns:id,status,created_at,updated_at,result,error).GET /jobsandGET /jobs/{id}to read from the database.CREATE TABLE IF NOT EXISTSguard on startup._jobsin-memory dict.Acceptance Criteria
GET /jobs/{id}returns the correct status/result.jobstable is created automatically on first startup if it does not exist.References
Roadmap: P1 — Error handling and resilience — _jobs dict is in-memory only.
Triage (AI-Manager)
Priority: P1 | Size: Medium | Agent: @senior-developer
Execution order: Wave 2 -- Should wait for #150 (fix db pooling) to land first.
Dependencies: Soft dependency on #150.
Scope: Create jobs table in PostgreSQL, migrate in-memory _jobs dict to database-backed storage, update GET /jobs and GET /jobs/{id}.
Closing: this issue is already implemented on main.
database.pycreates ajobstable withCREATE TABLE IF NOT EXISTS(line 177) during_init_schema().create_job,update_job,get_job,list_jobs).mark_stale_jobs_failed()marks previously-running jobs as failed (handles restart recovery)._jobsdict has been removed; all state is in PostgreSQL.