You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Derive compat claim-slot proof generations from the column cursor - #906
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).
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:
Rescue proves an empty ring.
The claim ring advances into slot 1 through claim_ring_state only.
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.
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.
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.
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.
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: 4
Check name
Status
Explanation
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
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.
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
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
full-ciRun the full CI matrix (Python build+test, E2E) on this PR
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Columnsring authority, rescue read each claim slot's generation fromclaim_ring_slots.generationand keyed its cached "closed" proof on it. The code assumed a 0.6 rotator stamps that column. It does not: 0.6 stamps onlyqueue_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
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. TheLedgerbranch 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.advance_ring_as_0_6, andset_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_tostampedclaim_ring_slots.generationitself; it now advances the claim ring throughadvance_ring_as_0_6, which moves only the columns.Other readers: nothing else in production code reads
claim_ring_slots.generationorlease_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:claim_ring_stateonly.On unmodified
mainit fails with nothing rescued.Checks
PostgreSQL 18.7, local:
cargo fmt --all --checkandSQLX_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-modellib: 154 passed.queue_storage_runtime_test: 363 passed.Not run: other test binaries, PostgreSQL 17 and 19, TLC.
Summary by CodeRabbit