Repository navigation
feat(purchase): read Redshift purchase claims across attempt lineages - #1846
Conversation
…aim read Move the pkg, aws, azure and gcp modules to 52d66feb, which reads claims by other purchase attempts when the journal offers a claim reader. Part of LeanerCloud/cloud-commitments-go#700 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…chased row per reservation ClaimedByOthers returns the reservation IDs that an attempt under a different token recorded as purchased. Migration 000162 adds a partial unique index so one reservation has at most one purchased row; it first fails with the duplicate IDs named if existing rows would violate it. RecordAttempt reports a violation as a clear error without pg detail. Part of LeanerCloud/cloud-commitments-go#700 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ManagerConfig.AttemptJournal now also requires common.ClaimReader, so a wrapper that hides ClaimedByOthers fails to compile instead of silently disabling the cross-lineage exclusion. Part of LeanerCloud/cloud-commitments-go#700 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ype against itself Part of LeanerCloud/cloud-commitments-go#700 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
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. |
|
APPROVED 2862901 by claude-qa-ui-4
CI run 42414809389 at this head: green. Local integration (testcontainers) passes: TestRecordAttempt_* (4), TestClaimedByOthers (and the empty-ids case), TestMigration_0161, TestMigration_0162 (2). Probes, each killed:
Non-blocking:
|
|
APPROVED 2862901 by claude-darling Cold review; I did not write this change. This is a money path with a migration. Two low test gaps, nothing blocking. Migration 000162
Deploy order. The new code doesn't depend on 162.
Go delta 0b677e1..52d66feb
Findings (low)
Probes (scoped, each reverted)
CI at this head: green, run 42414809389, including Unit Tests, Integration Tests (migrations, config, purchase) and Lint Code. |
|
Merge gate record for 2862901:
|
Part of LeanerCloud/cloud-commitments-go#700.
Deploy order
Migration 000162 must be applied before this code runs. It adds a unique index on
purchase_attempts (reservation_id) WHERE state = 'purchased', and the new store code turns a violation of that index into a clear "already recorded as purchased by another attempt" error. The migration number is re-checked against main at merge time and renumbered if another migration lands first.What
cloud-commitments-gofrom 0b677e1 to 52d66feb, which includes go#710. go#710 makes the Redshift purchase path skip nodes that another purchase lineage has already recorded as purchased, and makes reconcile report such nodes as Unknown, never NotFound. To do that, the provider asks the attempt journal through the optionalcommon.ClaimReader.PostgresStore.ClaimedByOthers(ctx, token, ids)returns the reservation IDs that a different idempotency token recorded as purchased:*PostgresStoreimplementscommon.ClaimReader.purchase_attemptsalready holds duplicate purchased reservation IDs. The error names them and says how to resolve them. Only then does it create the partial unique index.RecordAttemptturns a violation of the index (a race, or same-execution twins) into a clear error naming the masked token, instead of a raw 23505.internal/purchase:ManagerConfig.AttemptJournalnow requires the claim reader (AttemptJournal=common.AttemptJournal+common.ClaimReader), so a journal that cannot answer claims cannot be wired in. The post-DB manager gets the Postgres store; the pre-DB manager keeps nil.Operator note
If 000162's duplicate pre-check fails,
schema_migrationsis left dirty at 162. Resolve the duplicate rows (keep the true buyer, delete or reclassify the rest), setCUDLY_FORCE_MIGRATION_VERSION=161, then re-run the migration.Tests
TestClaimedByOthers: only another token's purchased IDs are returned, non-purchased states are ignored, and the view is symmetric per token.TestClaimedByOthers_EmptyIDsNoQuery.TestRecordAttempt_PurchasedReservationUniqueAcrossTokens.TestMigration_0162_UniquePurchasedReservation: the index blocks a second purchased row, and the down migration drops it.TestMigration_0162_PreCheckNamesDuplicates.internal/purchasefake journal implements the claim reader.🤖 Generated with Claude Code