Skip to content

Derive compat claim-slot proof generations from the column cursor - #906

Merged
hardbyte merged 1 commit into
mainfrom
ccr-37ca53f6-xza211-claim-proof-compat-key
Dec 2, 2026
Merged

hardbyte merged 1 commit into
mainfrom
ccr-37ca53f6-xza211-claim-proof-compat-key

Conversation

@hardbyte

@hardbyte hardbyte commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Fixes the compat-authority branch that 7f96541 added to closed_sealed_claim_slots_tx (the rescue slot proofs forward-ported in #870). #904 fixes the same frozen proof key on 0.6.

What was wrong

Under Columns ring authority, rescue read each claim slot's generation from claim_ring_slots.generation and keyed its cached "closed" proof on it. The code assumed a 0.6 rotator stamps that column. It does not: 0.6 stamps only queue_ring_slots.generation. Its claim and lease rotations move only the ring-state singleton, so those columns keep their install values (0 for slot 0, -1 for the rest).

With 0.6 rotators in the fleet, a proof kept its key while the ring rotated into the slot and out again. Rescue then skipped a dead claim taken in that slot until the proof expired (CLAIM_SLOT_PROOF_TTL, 30 s).

What changed

  • Under Columns, each slot's generation is derived from the column cursor read at the start of the proof (ring_slot_generation), as Backport unique-claim, gauge and claim-slot proof fixes for 0.6.20 #904 does on 0.6. The Ledger branch is unchanged.
  • RingFamily::slots_relname's doc comment no longer says a 0.6 rotator stamps the per-slot generation. The compat rotator's comment says 0.6 stamps only the queue ring's.
  • The test helpers that emulate a 0.6 rotator (advance_ring_as_0_6, and set_ring_authority's compat shape) now stamp only the queue ring's per-slot generation. test_queue_storage_rescue_walks_the_current_slot_a_0_6_rotator_advanced_to stamped claim_ring_slots.generation itself; it now advances the claim ring through advance_ring_as_0_6, which moves only the columns.

Other readers: nothing else in production code reads claim_ring_slots.generation or lease_ring_slots.generation. Main's own compat rotator stamps all three rings' per-slot generation. That is harmless, and the fix doesn't depend on it.

Test

test_queue_storage_rescue_reproves_a_slot_a_0_6_rotator_rotated_through, under compat authority:

  1. Rescue proves an empty ring.
  2. The claim ring advances into slot 1 through claim_ring_state only.
  3. A claim taken there dies.
  4. The ring advances to slot 2 the same way.
  5. The next rescue must rescue the claim.

On unmodified main it fails with nothing rescued.

Checks

PostgreSQL 18.7, local:

  • cargo fmt --all --check and SQLX_OFFLINE=true cargo clippy --all-targets --all-features -- -D warnings: clean.
  • scripts/check-advisory-locks.py, scripts/check-transaction-isolation.py, scripts/ci-test-shard.sh check, scripts/check-commit-metadata.py: pass.
  • awa-model lib: 154 passed.
  • queue_storage_runtime_test: 363 passed.

Not run: other test binaries, PostgreSQL 17 and 19, TLC.

Summary by CodeRabbit

  • Bug Fixes
    • Improved recovery of aged claims after queue activity in compatibility mode. Claims in intervening slots are now found during rescue, including when the claim position has advanced.
    • Compatibility upgrades now preserve the expected behavior of lease and claim tracking while updating queue tracking. This prevents unrelated slot-generation changes from affecting claim recovery.

@hardbyte hardbyte added the full-ci Run the full CI matrix (Python build+test, E2E) on this PR label Dec 1, 2026 — with Claude

hardbyte commented Dec 1, 2026

Copy link
Copy Markdown
Owner Author

The description footer ("Generated by Claude Code") was added automatically when this PR was opened through the API. Please delete it from the description so commit-metadata passes.


Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 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-12-01T11:19:59.383789Z f546557 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 Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f546557 and 10a5e6d.

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

No actionable comments were generated in the recent review.

Walkthrough

Claim-slot proof generations under columns authority now derive from the cursor and slot count instead of stored slot generations. Compatibility test helpers model 0.6 generation stamping on the queue ring only, and a regression test verifies rescue of a stale claim in an unchanged claim slot.

Changes: Compat claim rescue

Layer / File(s) Summary
Claim-slot proof generation
awa-model/src/queue_storage.rs
Under columns authority, claim-slot proof generations now derive from the cursor and slot count. Slots not yet opened are omitted. Ledger authority continues to use ledger generations.
Compatibility setup and regression coverage
awa/tests/queue_storage_runtime_test.rs
The 0.6 helper stamps slot generations only for the queue ring. The regression test advances the claim ring without changing slot generations, then verifies rescue finds a stale claim in an intervening slot.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

  • Issue 861 describes rescue skipping sealed claim slots whose claims are closed. This change updates claim-slot proof generation used by rescue.

Possibly related PRs

  • hardbyte/awa#878: It applies cursor-based authority handling to ledger-only paths, including rescue claim-slot ordering.
  • hardbyte/awa#872: It changes queue-slot generation and cursor writes under compatibility authority, which share the generation and cursor contract involved here.

Suggested reviewers: claude

Merge Risk: Minimal · previous review f5465

This change makes rescue re-prove claim slots that a 0.6 rotator rotated through, so dead claims are no longer skipped until the proof cache expires. No concrete merge-blocking risk remains in the code. The PR description footer still needs to be removed so the commit-metadata check passes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: under compat (0.6) authority, claim-slot proof generations are now derived from the column cursor. The raw summary confirms that columns authority now derives generati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: under compat (0.6) authority, claim-slot proof generations are now derived from the column cursor. The raw summary confirms that columns authority now derives generations from the current cursor and slot count, and the objectives describe the same fix for the frozen proof key. The title is specific and matches the changeset.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • 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 rabbit checks the cursor’s trail
While claim-slot proofs no longer fail
The queue keeps stamped generations bright
Old claims emerge from slots at night
The rabbit hops; rescue gets it right

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9c51913 and f546557.

Files selected for processing: 2

  • awa-model/src/queue_storage.rs
  • awa/tests/queue_storage_runtime_test.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

7f96541 made closed_sealed_claim_slots_tx read each slot's generation
from claim_ring_slots under compat ring authority, on the premise that a
0.6 rotator stamps that column. It does not: 0.6 stamps only
queue_ring_slots.generation, and its claim and lease rotations advance
only the ring-state singleton. With 0.6 rotators in the fleet a cached
"closed" proof kept its key while the ring rotated into the slot and out
again, and rescue skipped a dead claim taken there until the proof
expired.

Under compat authority each slot's generation is now derived from the
column cursor read at the start of the proof (ring_slot_generation). The
ledger branch is unchanged. The RingFamily::slots_relname doc comment is
corrected, and the test helpers that emulate a 0.6 rotator stamp only the
queue ring's per-slot generation, as 0.6 does.
hardbyte added a commit that referenced this pull request Dec 2, 2026
Add test_compat_rescue_after_released_leader_rotates_claim_ring to the
rolling-upgrade rehearsal. Under compat ring authority, a current runtime
leads and proves the sealed claim slots closed. It then loses leadership
without restarting, so its proof cache survives. A released 0.6.19 leader
rotates the claim ring into a slot, a released claimer takes a claim there
and is killed, and the 0.6.19 leader rotates past the slot. Leadership
returns to the same current process, which must rescue the dead claim
within a bound that ends before any proof it made could expire.

The 0.6 rotation is the released artifact's own, not SQL that emulates it.
The cell fails without #906's fix: the cached proof hides the dead claim
until it expires.

mixed_fleet_helper.py gains three opt-in settings the cell uses:
MIXED_MAINTENANCE_LEADER, MIXED_HEARTBEAT_STALENESS_MS and
MIXED_CLAIM_ROTATE_INTERVAL_MS.
@hardbyte
hardbyte force-pushed the ccr-37ca53f6-xza211-claim-proof-compat-key branch from f546557 to 10a5e6d Compare December 2, 2026 16:38
@hardbyte
hardbyte merged commit fe21c4c into main Dec 2, 2026
64 checks passed
@hardbyte
hardbyte deleted the ccr-37ca53f6-xza211-claim-proof-compat-key branch December 2, 2026 18:01
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