forked from 0xWheatyz/SPARC
Persist async batch job state in PostgreSQL so it survives API restarts #8
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?
Roadmap Reference
P1 — Error handling and resilience
Problem
_jobsinapi.pyis an in-memory dict. Any API restart (e.g. after a crash, rolling deploy, or container restart) wipes all job history. Users polling/jobs/{job_id}get 404 errors for jobs that were started before the restart.What to do
jobstable to the PostgreSQL schema (columns:job_id,status,progress,total_companies,completed_companies,result_json,error,created_at,updated_at)._run_batch_joband the job status endpoints to read/write from the database instead of_jobs._jobsand_job_countermodule-level globals.scripts/init_database.py) for the new table.Acceptance Criteria
/jobs/{job_id}after restart./jobslists persisted jobs correctly.runningstate at restart is markedfailed(orunknown) on next startup to avoid stuck states.Triage: P1 error handling/resilience, medium complexity. Assigned to @AI-Engineer. Delegating to @senior-developer agent for architectural refactoring work.
Implementation complete in PR #34 (feature/persist-job-state). Awaiting review.
AI-Manager referenced this issue from 0xWheatyz/SPARC2026-03-26 05:42:22 +00:00