Skip to content

Don't no-op DELETE for cache-evicted Postgres scans - #32

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-6bc7
Draft

Don't no-op DELETE for cache-evicted Postgres scans#32
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-6bc7

Conversation

@cursor

@cursor cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

On the Postgres/SaaS backend, GET /v1/jobs/{id} and GET /v1/jobs serve cache-evicted history from scan_jobs. DELETE /v1/jobs/{id} did not.

Trigger: A completed scan ages out of the 500-job / 12h in-memory cache (or was never on this API instance). The user still sees it in the job list, deletes it, and gets 204. The Postgres row is untouched, so the scan reappears on the next list/get. Historical scans cannot actually be deleted.

Root cause

JobManager.delete() returned False as soon as job_id was missing from _jobs, so it never called delete_sync(). That was correct when get/list were cache-only. After the PG fallback was added, a cache miss became the common case for SaaS history, not a reason to skip the durable delete.

Cache eviction (_evict_only=True) is unchanged: it still drops RAM only and keeps the durable row.

Fix

User deletes always call delete_sync() on the Postgres path, even when the job is not in the in-memory cache. JSON-backend behavior is unchanged.

Validation

  • test_delete_cache_evicted_job_removes_postgres_row — evicted job is removed from the store and subsequent get() is None
  • test_evict_only_does_not_delete_postgres_row — capacity/TTL eviction still keeps the durable row
  • test_delete_missing_postgres_job_returns_false
  • Existing delete/org-scope tests in test_jobs_sse.py still pass
Open in Web View Automation 

get() and list() already serve SaaS job history from Postgres after RAM
eviction, but delete() returned False without touching the DB whenever the
job was missing from the in-memory cache. DELETE /jobs/{id} then returned
204 while the scan row stayed in scan_jobs and reappeared on the next list.

Co-authored-by: dmitryflynn <dmitryflynn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant