FORGE-88: guarded outbox/readiness claims and resource_locks lease (Phase 3 step 2) #729
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!729
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "FORGE-88-outbox-lease"
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?
FORGE-88 step 2 of 7 (FORGE-69 D1 migration, Phase 3). This covers inventory T6, T9 and T10 and the three lock sites in notification-outbox.ts:23, readiness-webhook.ts:114 and node-access-db.ts:84. Step 1 (#720, atomic adapter) is merged.
What
FOR UPDATE SKIP LOCKEDplus per-row updates in a transaction become one statement:UPDATE notification_outbox SET lease… WHERE id IN (SELECT … ORDER BY next_attempt_at, id LIMIT n) AND <eligible> RETURNING *. Repeating the eligibility predicate on the outer UPDATE is what keeps the claim exclusive on Postgres. A drainer blocked on a row re-checks it after the winner commits, and skips it because the lease is no longer expired. Acks stay fenced bylease_token.READINESS_VISIT_COOLDOWN_MS(5 s) is not reclaimed, so each link is visited by one reconciler per round. It now also returnslinkIds.pg_try_advisory_xact_lockbecomes aresource_lockslease (new@forgegraph/api/lib/resource-lease).INSERT … ON CONFLICT (key) DO UPDATE … WHERE expires_at < now RETURNING token. Contenders fail fast withoperation_in_progress, as before.node_access_resourceslease CAS stays the write fence.0120_resource_locks.sql. Additive and idempotent, and grants to forgegraph_dbcooper. I'll apply it to production right after merge withfg db migrate.Concurrency tests (rewritten to the new semantics)
notification-outbox.concurrency.test.ts:node-access.concurrency.test.ts:registry-leasesandreview-concurrencyare unchanged; review moves with step 5.Local, on real Postgres 17: concurrency lane 18/18, readiness and kanbanger database tests 15/15, full api database lane green earlier, and api
tscclean.Remaining FORGE-88 steps: 3 (BATCH/READ sites; branches FORGE-88-batch-routers, FORGE-88-batch-web and FORGE-88-read-evidence are ready behind this), 4 GUARD sites, 5 RepositoryCoordinator DO, 6 deploy route guards, 7 lint at error.
🤖 Generated with Claude Code