Skip to content

fix(storage): keep claim tombstone checks correlated (0.6) - #715

Merged
hardbyte merged 1 commit into
release/0.6.6from
claude/beautiful-dijkstra-vqdyqy
Nov 11, 2026
Merged

hardbyte merged 1 commit into
release/0.6.6from
claude/beautiful-dijkstra-vqdyqy

Conversation

@hardbyte

Copy link
Copy Markdown
Owner

0.6 port of #713 by @Wallace99, fix-first on the 0.6 line per the branch policy in #383. #713 targets main with migration v056; the 0.6 series cannot add a migration version, so this delivers the same fix as a repeatable schema patch. Forward-port to main in the bundled port.

Problem

A claim marks each candidate row with EXISTS over ready_tombstones. For a small batch PostgreSQL can plan that EXISTS as a hashed subplan, which reads the slot's whole tombstone partition on every claim although the lookup index exists. In the regression test a 32-row claim sequentially reads 10,000 tombstone rows on unpatched 0.6 functions.

Change

  • OFFSET 0 in both tombstone subqueries of claim_ready_runtime keeps each check correlated: one index probe per candidate row. Results are unchanged.
  • The v023 installer writes the fenced check into new substrates.
  • New schema patch correlated_claim_tombstones rewrites claim_ready_runtime in every installed queue-storage schema from the function's own definition (pg_get_functiondef), so signature, owner, privileges and settings are unchanged. A function that already carries the fence does not match and is left alone.
  • The patch's probe reports the installer and each claim function that still has an unfenced check, so a custom schema restored or prepared with old functions keeps the patch pending.

Differences from #713

  • Delivered as R__correlated_claim_tombstones.sql, not V56.
  • Schema discovery follows the other 0.6 patches (schemas with claim_ready_runtime and a partitioned ready_tombstones) and takes the per-schema install advisory lock.
  • On 0.6 both tombstone checks live in claim_ready_runtime; there are no per-slot claim_ready_slot_<n> functions. The patch still matches that name pattern, which is harmless here.

Compatibility

  • Function replacement only. It takes no lock on any awa or queue-storage table; work scales with the number of claim functions, not job count.
  • Function names, arguments, results and the claim protocol are unchanged, so 0.6.16 binaries run the same on a patched or an unpatched schema. Binaries and the patch can roll in either order.
  • External migration runners apply R__correlated_claim_tombstones.sql after V40, as the owner of the claim functions.

Tests

  • New awa-model/tests/claim_tombstone_plan_test.rs, ported from fix(storage): keep claim tombstone checks correlated #713: legacy and receipt modes, custom and generic plans, tombstone hits and misses on real 32-row claims. It restores the released function bodies, checks the probe names each unfenced function, applies the patch, checks replay leaves the body unchanged, and asserts zero sequentially scanned tombstone rows. Passes on PG18. Without applying the patch it fails with 10,000 rows scanned.
  • patch_upgrade_rehearsal_test expectations include the new patch; that test needs released binaries and runs in CI.
  • Locally on PG18: awa-model migration lib tests, migrate_patch_cli_test and runtime_control_test pass. migration_test was still running when this was opened.
  • cargo fmt and clippy (awa-model, awa, awa-cli, all targets and features) pass.
  • Not run locally on PG17.

Docs

  • docs/migrations.md: the new repeatable patch.
  • CHANGELOG: an Upgrading note and a Fixed entry.

Generated by Claude Code

@hardbyte hardbyte added the full-ci Run the full CI matrix (Python build+test, E2E) on this PR label Nov 11, 2026 — with Claude
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T03:56:47.544946Z 4b89732 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6178b5e9-f398-4b91-a32b-a7d5d5687086

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A claim marks each candidate row with EXISTS over ready_tombstones. For a small batch PostgreSQL could plan that as a hashed subplan, reading the slot's whole tombstone partition on every claim although the lookup index exists. OFFSET 0 in the subquery keeps it one index probe per candidate row.

The installer writes the fenced check into new substrates. The correlated_claim_tombstones schema patch rewrites claim_ready_runtime in every installed queue-storage schema from its own definition, so signature, owner, privileges and settings are unchanged. Function replacement only; no table lock.

0.6 port of #713.

Co-authored-by: Wallace99 <5481339+Wallace99@users.noreply.github.com>
@hardbyte
hardbyte force-pushed the claude/beautiful-dijkstra-vqdyqy branch from 4b89732 to b817fbc Compare November 11, 2026 03:58
@hardbyte
hardbyte merged commit 5269550 into release/0.6.6 Nov 11, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the full CI matrix (Python build+test, E2E) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant