Repository navigation
Conversation
…edRecently (#429) CreateQueue was unconditionally idempotent: it returned the existing queue's URL regardless of what the request asked for, so two stacks or two test cases claiming one queue name with different settings both "succeeded" and the second silently inherited the first one's configuration. That is a confidently wrong answer rather than a missing error, and it left the consumer's error branch unreachable. AWS documents two failures here, and neither was modeled. QueueNameExists (400) now fires when a name is reused with differing attribute values. Only attributes present in the request are compared, per the error's own definition in the CreateQueue reference — "only if the request includes attributes whose values differ from those of the existing queue" — so an omitted attribute is no opinion. That is also the only reading that keeps substrate's own CFN path working, since deploySQSQueue forwards just the properties a template declares and a template dropping one would send a strict subset on re-deploy. An existing queue's unset attributes resolve through the same defaults getQueueAttributes reports before comparing, so VisibilityTimeout=30 against a bare queue is not a conflict — comparing raw map entries would reject a request AWS accepts. FifoQueue is resolved from the queue's own flag, because substrate derives it from the .fifo suffix and never copies it into Attributes; without that, re-creating a FIFO queue with FifoQueue=true — what every SDK and template sends — would be rejected. Attributes are checked in sorted order so the attribute named in the message is reproducible. QueueDeletedRecently (400) is seedable via deletedRecentlyMisses on the existing /v1/sqs/consistency seed: same endpoint, same name-over-wildcard precedence, same DELETE, same state reset. Counted rather than timed for the reason the lookup windows are — the real condition is a 60-second wall-clock window, and a wall-clock window would make the assertion depend on how long the rest of the test took. Unlike the lookup counters it is not gated on the queue existing, since QueueDeletedRecently is precisely the absent case; a create that hits an existing queue is an idempotent success and does not spend the budget. The counter defaults to 0, so an unseeded recreate is still instant. Both codes were verified to dispatch before shipping, applying the #413 lesson: botocore's SQS model declares both exception shapes and lists them under CreateQueue.errors, and aws-sdk-go-v2/service/sqs deserializers.go matches both with strings.EqualFold. Neither has a legacy alias, unlike QueueDoesNotExist. Filed #439 rather than fixing it here: sqsAttributeDefaults mirrors getQueueAttributes' stale MaximumMessageSize of 262144 where AWS documents 1 MiB. Mirroring keeps the comparison and read paths from disagreeing about a queue's effective attributes; correcting the value changes GetQueueAttributes output and belongs in its own change. Mutation-tested: disabling the conflict check, the defaults resolution, and the FifoQueue derivation each fails the tests that cover it. The FIFO case initially did not fail, because the test passed FifoQueue=true on the first create so the value landed in Attributes and the derivation branch was never reached; the test is now split so the derived and standard-queue branches are both exercised. Closes #429
Owner
Author
|
Superseded by #442. GitHub auto-closed this when its base branch |
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.
Closes #429
The defect
createQueuewas unconditionally idempotent — it returned the existing queue's URL regardless of what the request asked for. Two stacks or two test cases claiming one queue name with different settings both "succeeded", and the second silently inherited the first one's configuration. That is a confidently wrong answer rather than a missing error, and the consumer's error branch was unreachable. AWS documents two failures onCreateQueue; neither was modeled.Stacked on #438 (
fix/431-run-instances-counts) — both touchCHANGELOG.mdanddocs/services.md. Base retargets tomainautomatically when #438 merges.QueueNameExists— state-determined, no seed400 when a name is reused with differing attribute values; same name with the same values stays idempotent.
No seed, because the condition is entirely determined by state: it fires on the real mistake rather than only when a harness remembers to arm it.
Which differences count
Only attributes present in the request are compared. An omitted attribute is "no opinion", not an assertion of its default.
The CreateQueue reference says two things that pull in different directions — that providing "the exact same names and values for all its attributes" returns the existing URL, and that the error fires "only if the request includes attributes whose values differ from those of the existing queue". I took the narrower reading: the first is a sufficient condition for idempotency, not a necessary one, so it does not contradict the error's own definition.
It is also the only reading that keeps substrate's own CFN path working.
deploySQSQueueforwards only the properties a template declares, so a stack that dropped a property between deploys would send a strict subset on re-deploy and fail to update at all under the strict reading.Resolving through defaults
An existing queue's unset attributes resolve through the values
getQueueAttributesreports before comparing. A queue created with no attributes has an empty map but observably reportsVisibilityTimeout=30, so a request namingVisibilityTimeout=30asks for exactly what it already has — comparing raw map entries would reject a request AWS accepts.sqsAttributeDefaultsdeliberately mirrorsgetQueueAttributes' inline fallbacks rather than the AWS reference, so the comparison and read paths cannot disagree about a queue's effective attributes. That carries one known staleness through:MaximumMessageSizeis 262144 here where AWS documents 1 MiB. Filed as #439 rather than smuggled in, since correcting it changesGetQueueAttributesoutput.The FifoQueue trap
Substrate derives
FifoQueuefrom the.fifoname suffix and never copies it intoAttributes. A naive map comparison would compare"true"against an absent value and reject the most ordinary FIFO re-create there is —FifoQueue=true, what every SDK and CloudFormation template sends. Resolved from the queue's own flag instead, and pinned by test.Attributes are checked in sorted order, so the attribute named in the message is deterministic; a message varying by map iteration order would make the error irreproducible.
The message carries AWS's documented wording plus the offending attribute name, which AWS's own text omits — without it the error is nearly undiagnosable for a caller holding a large attribute set.
Seedable
QueueDeletedRecentlyAWS requires a 60-second wait after
DeleteQueuebefore the same name can be reused. Substrate keeps no memory of a delete, so a consumer's delete → recreate → retry loop had no reachable error branch.curl -X POST http://localhost:4566/v1/sqs/consistency \ -d '{"queueName":"run-q","deletedRecentlyMisses":2}'Rides on the existing
/v1/sqs/consistencyseed as a third counter: same endpoint, same name-over-wildcard precedence, sameDELETE, same state reset. Counted rather than timed for the reason the lookup windows are — the real condition is a wall-clock window, and a wall-clock window would make the assertion depend on how long the rest of the test took.Unlike the two lookup counters it is not gated on the queue existing, since
QueueDeletedRecentlyis precisely the absent case — gating it on existence would make it unreachable. A create that hits an existing queue is an idempotent success and does not spend the budget. The counter defaults to 0, so an unseeded recreate is still instant.Both codes verified to dispatch
Applying the #413 lesson rather than assuming:
CreateQueue.errors.service/[email protected]—deserializers.go:619,622matches both withstrings.EqualFold.Neither has a legacy alias, unlike
QueueDoesNotExist.Blast radius
No existing test creates the same queue twice with attributes. The only re-create path is CFN (
UpdateStack→Deploy→deploySQSQueue), which forwards only declared properties — hence the "no opinion" decision. All existingTestSQS/TestCFNtests pass unchanged.Tests
28 subtests in the new
emulator/sqs_createqueue_test.go, covering both wire protocols: the conflict cases, the idempotent cases including explicit-value-equal-to-default and subset, the three FIFO branches, message content, determinism across 20 runs, that a conflict creates nothing, the seeded window, that it does not apply to an existing queue, counter independence, the wildcard, negative rejection, and the state-failure path.Mutation-tested. Disabling the conflict check, the defaults resolution, and the
FifoQueuederivation each fails the tests covering it. The FIFO case initially did not fail: the test passedFifoQueue=trueon the first create, so the value landed inAttributesand the derivation branch was never reached. The test is now split so the derived and standard-queue branches are both exercised — a real coverage gap that green tests hid.Verification
gofmt,go build ./...,go vet ./...,golangci-lint run ./...(0 issues),make test(race),test/e2e,make docs-reference-check docs-versions. All internaldocs/services.mdanchors verified to resolve.