Skip to content

fix(queue): atomically claim queued runs#1206

Merged
federicodeponte merged 1 commit into
mainfrom
fix/1162-atomic-run-claim
Jun 15, 2026
Merged

fix(queue): atomically claim queued runs#1206
federicodeponte merged 1 commit into
mainfrom
fix/1162-atomic-run-claim

Conversation

@federicodeponte

Copy link
Copy Markdown
Member

Summary

  • add RunRepository.claim_queued() as a compare-and-set transition from queued to running
  • update the drain loop to dispatch only when this process wins the claim
  • release the execution semaphore when a stale queued row has already been claimed elsewhere
  • add regressions for repository CAS behavior and stale-row drain-loop double-dispatch prevention

Fixes #1162.

Verification

  • python3 -m ruff check apps/api/db/interface.py apps/api/db/sqlite.py apps/api/run_service.py tests/test_s35_queue.py
  • python3 -m compileall -q apps/api/db/interface.py apps/api/db/sqlite.py apps/api/run_service.py
  • python3 -m pytest tests/test_s35_queue.py -q -> 16 passed

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workeros Ready Ready Preview, Comment Jun 15, 2026 2:25pm

Request Review

@federicodeponte
federicodeponte force-pushed the fix/1162-atomic-run-claim branch from aed29e6 to df0cf81 Compare June 15, 2026 13:39
@federicodeponte
federicodeponte force-pushed the fix/1162-atomic-run-claim branch from df0cf81 to bd8919e Compare June 15, 2026 14:24
@federicodeponte
federicodeponte merged commit ba9cda0 into main Jun 15, 2026
8 checks passed
@itachi-hue
itachi-hue deleted the fix/1162-atomic-run-claim branch June 20, 2026 04:05
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.

[Backend][P1][queue] Cloud drain loop has no atomic run claim, so replicas can execute the same queued run twice

1 participant