Repository navigation
fix(sqs): the wildcard consistency seed cannot be double-consumed (#582) - #589
Merged
Merged
Conversation
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Consuming a seeded consistency miss is a read-modify-write and
StateManagerhas nocompare-and-swap, so the decrement was serialized under a mutex striped by queue
name. The
"*"wildcard seed is shared by every queue but the lock was not: twoconcurrent lookups on different names took different stripes, both read the same
budget, both decremented it and both
Put. One seeded miss consumed twice.The issue notes this would flake rather than fail reliably. It does not — with enough
concurrency it fails every time. A wildcard seed of 16 driven by 32 concurrent
GetQueueUrlcalls on distinct queues reported 27 misses, then 32 on the nextrun: a harness seeding "the next N lookups in this suite miss" saw more than N, and
inconsistently.
The fix, and where it deviates from the issue
The issue proposes adding
seedMualongsidequeueMuand specifies astripe → seed-mutex lock order. Measured before writing any code:
queueMu.lockhadexactly one call site —
consumeQueueMissitself. Nothing else used the stripe set,so it is replaced rather than supplemented. That removes the lock-order rule along
with the hazard it guarded, which is strictly better than documenting an ordering
between two locks when one suffices. Seed consumption is a harness-frequency
operation, so striping buys nothing here.
The result is the shape
S3Plugin.consumeConditionalConflictalready has — the seedthis was found next to, in #540 — and the comment cross-references it so the two read
as one decision rather than two coincidences.
Acceptance criteria
each seeded miss exactly once.
exactly M report the deviation, under
-race, failing before the fix —measured at 27 and 32 against a seeded 16.
wildcard when a name-scoped seed is exhausted (
sqs_consistency_test.go'sexisting cases pass unchanged).
consumeQueueMissalongwith the reasoning, since the type it was attached to is gone. It now records
that the guarantee was airtight for the name-scoped path and not for the
wildcard one, keeping the two paragraphs that are still true:
StateManagerhasno compare-and-swap, and the guarantee is process-local.
CHANGELOG.mdunder### Fixed.Tests
TestSQS_Consistency_ConcurrentWildcardAcrossQueues: 32 queues sharing one wildcardseed of 16, released from a single
startchannel to maximize overlap. More queuesthan budget on purpose — the overspend is only observable as a count if there are
lookups left over to be refused. It also asserts the budget really is spent
afterwards, so a count that comes out right because misses were lost rather than
double-spent still fails.
The pre-existing single-name concurrency test keeps its assertion and gains a comment
saying which case it does not cover, so the two are not mistaken for duplicates.
Mutation testing
Three mutants, anchor-count asserted,
gofmt+vetgated,-race,-count=3:queueMuGet(the plan's mutant)Verification
Full gate green:
gofmt,go build,go vet,golangci-lint(0 issues),make test(race),make docs-reference-check docs-versions, docs site build,test/e2evet + test.Live against
substrate server --address :4673with the real AWS CLI(
AWS_MAX_ATTEMPTS=1): 16 concurrentget-queue-urlcalls on 16 distinct queuesagainst a wildcard seed of 8 → 8 misses, 8 successes, three runs in a row, and
wq-0resolving normally once the budget is spent.Closes #582