Repository navigation
fix(worker): re-check document after the legacy claim_ingestion_jobs row lock - #3636
Conversation
…row lock Follow-up to #3633 for the three-argument claim_ingestion_jobs(text, integer, integer). It picked candidates from a snapshot, locked the picked document's authority and sibling leases, then locked the job row without checking that the row still belonged to the picked document, so a job re-pointed in that window was leased under the old document's authority. New migration 20261018062736 replaces the three-argument function in place (same signature, defaults, grants and behaviour) and, after the job row lock, skips the job unless it still belongs to the picked document. A skipped job stays pending with no lease and no consumed attempt. tests/sql/ingestion-legacy-claim-recheck-after-lock.sql wraps the authority lock to re-point the job between pick and lock. It fails against the 20261013075944 function and passes with this one. schema.sql mirrors the migration; the hash is sealed with npm run migrations:seal (append-only). The drift manifest follows from the Migration replay artifact.
There was a problem hiding this comment.
BigSimmo has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Review limit reachedYour organization has reached its usage spending cap. Adjust your spending cap in the billing tab. Next included review available in 8 minutes. View limit details
Comment |
|
Updates to Preview Branch (fix/legacy-claim-recheck-after-lock) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
|
Claude encountered an error after 2s —— View job I'll analyze this and get back to you. |
PR Summary by QodoPrevent legacy ingestion claims from leasing re-pointed jobs
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
🏁 CodeAnt Quality Gate ResultsCommit: ✅ Overall Status: PASSEDQuality Gate Details
|
Code Review by Qodo
No findings for this group No findings for this group No findings for this group Resolved findings 1.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Qodo Fixer✅ Merged (0) · ☑ Fixed (0) Process
|
CodeAnt PR Risk: Low Risk
Assessed commit: |
|
Auto-fix isn't included in your plan ↗ |
…recheck Byte-identical to the drift-manifest-39104250354 artifact that scripts/generate-drift-manifest.ts (npm run drift:manifest) produced in the Migration replay job of run 39104250354 for be0b278. Only claim_ingestion_jobs(text,integer,integer) def_hash and the schema sha change; no hand edits.
Code Review ✅ Approved 1 closed / 1 findings🔴 High risk · The SECURITY DEFINER claim now checks document identity before leasing; a flaw could let ingestion run under the wrong document’s authority. Re-checks the legacy three-argument ✅ 1 closedClosed: Quality: PR plans auto-merge on a migrations PR, which repo policy forbids
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Approved For more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Important Your trial ends in 3 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
|
Code review by qodo was updated up to the latest commit 2d1906b |
Summary
claim_ingestion_jobs(text, integer, integer)picks candidates from a snapshot, takes the picked document's authority lock and sibling-lease locks, then locks the job row withFOR UPDATE SKIP LOCKED, but never checked that the locked row still belonged to the picked document. A job re-pointed at another document in that window was leased under the old document's authority and sibling-lease check.supabase/migrations/20261018062736_recheck_legacy_ingestion_claim_document_after_job_lock.sqlreplaces the three-argument function in place. After the job row lock it skips the job unlessv_job.document_idstill equals the picked document. A skipped job stays pending with no lease and no consumed attempt, the same as every other skip in the loop. Signature, defaults, grants, return shape and every other branch are unchanged. The five-argument function (fix(worker): re-check document and allowlist scope after claim_ingestion_jobs row lock #3633) is not touched.tests/sql/ingestion-legacy-claim-recheck-after-lock.sql, modelled ontests/sql/ingestion-claim-recheck-after-lock.sql(run by the Migration replay job with everytests/sql/*.sql). It wrapslock_ingestion_document_authorityinside its rolled-back transaction so the job is re-pointed between the pick and the job row lock. It covers a re-point to a same-type document and to a different file type, plus a control and a follow-up claim that leases the job under its new document.supabase/schema.sqlmirrors the migration (same pattern as fix(worker): re-check document and allowlist scope after claim_ingestion_jobs row lock #3633),supabase/applied-migration-hashes.jsonvianpm run migrations:seal(append-only, no existing entry changed).supabase/drift-manifest.jsonwill be taken byte-for-byte from this PR's Migration replay artifact (npm run drift:manifestneeds Docker, which isn't available locally).database.types.tsis unchanged because the signature is unchanged.Areas touched: Data platform and access
Verification
legacy claim: a job whose document changed after the pick must not be leased under the old document's authority, and the file-type case); the control passes. With the new migration applied the whole file passes.node scripts/check-migration-immutability.mjs:Migration immutability guard passed: 321 shipped migrations unchanged.check:migration-role: passed.check:function-grants:OK — all 130 SECURITY DEFINER public function(s) are revoked from PUBLIC.supabase-schema,migration-sql,migration-immutability,migration-history-guards,hosted-migration-role-guard,worker-row-contract,drift-detection: 300/301 passed; the one failure is the expected stale drift manifest before the CI artifact lands.SKIP_DRIFT_GUARD=1override, as in fix(worker): re-check document and allowlist scope after claim_ingestion_jobs row lock #3633, because the manifest can only be generated in CI. No other guard was skipped.lock_ingestion_document_authority.Risk and rollout
supabase/migrations/**; merging applies it to the live database. The owner approved this PR including auto-merge (relayed 14:26 AWST 2026-10-18).