Repository navigation
fix(rds,elasticache): the Marker names the last record of its page (#887) - #914
Merged
Merged
Conversation
) DescribeDBInstances, DescribeDBClusters and DescribeCacheClusters implemented Marker as a decimal offset into the sorted listing. All five relevant AWS pages document the parameter positionally — "the response includes only records beyond the marker, up to the value specified by MaxRecords" — so an offset diverges from the published contract as soon as the set changes behind the cursor: deleting a record already reported shifted every later page and lost one the caller never saw. The offset was also parsed with strconv.Atoi and the error discarded, so any unparseable Marker became 0 and was answered with page one. The Marker now names the last record of the previous page and the next page is the records sorting strictly after it, the pattern ListBuckets' continuation-token already uses. It is base64, so a marker substrate did not issue is refused with InvalidParameterValue/400 — published for ElastiCache, recorded as substrate's reading for RDS. Truncation is decided on the next matching record, so a full last page carries no Marker. Closes #887.
5 tasks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
9 tasks
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 #887.
What was wrong
Three operations — RDS
DescribeDBInstancesandDescribeDBClusters, ElastiCacheDescribeCacheClusters— implementedMarkeras a decimal offset into the sorted listing:All five relevant AWS pages document the parameter positionally, in identical words: "the response includes only records beyond the marker, up to the value specified by
MaxRecords". An offset diverges from that in two ways a caller can observe over the wire.1. A record removed behind the cursor loses a record the caller never sees. Paging five instances two at a time and deleting the first after page one, page two was answered as
items[2:]of a now-four-record listing, so the third record was never reported. The caller's loop terminated normally with four of five records and nothing to indicate the fifth had been skipped. A record created behind the cursor repeated one instead.2. A
Markersubstrate never issued was answered with page one.strconv.Atoi's error was discarded, so any unparseable marker became0. A consumer that persisted a marker across a restart, or truncated one, silently restarted its walk.The fix
emulator/query_marker_pagination.gois one new file holding the whole contract, so the three sites cannot drift. TheMarkernow names the last record of the previous page and the next page is the records sorting strictly after it — the key-valued-cursor patternListBuckets'continuation-tokenalready uses (s3_list_buckets.go). Consequences:InvalidParameterValue/ 400 rather than served page one. That code is published for ElastiCache (onAPI_DescribeCacheClustersandAPI_DescribeReplicationGroups); the two RDS pages publish only their NotFound faults, so for RDS it is recorded in the doc comment as substrate's reading.Markerand costs the caller no round trip to an empty page.Lexicographic order itself remains substrate's reading — none of the five pages states an order. That is exactly why the cursor has to be key-valued: the guarantee is what makes "beyond the marker" well defined at all.
The audit (#887's actual scope)
All 128 non-test
Listcall sites across 46 files were classified — not the ~60 the issue estimated:No new tier-1 operation exists. Eleven further AWS pages were read (RDS ×2, ElastiCache ×3, API Gateway
GetRestApis, CloudWatchDescribeAlarms/ListMetrics, SSMDescribeParameters/GetParametersByPath, EC2's Query request page) and none publishes an ordering statement. EC2 is settled by a blanket disclaimer covering the whole family: "The order of the elements in the response, including those within nested structures, might vary. Applications should not assume that the elements appear in a particular order."ListMultipartUploadsremains the only documented order in the tree.Two corrections to #887's own body, both recorded on the issue: only one of ElastiCache's four describes has a cursor (
describeReplicationGroups,describeCacheSubnetGroupsanddescribeCacheParameterGroupsimplement no pagination at all — filed separately), and the site count is 128, not ~60.Adjusted test, recorded as a finding
Per the issue's AC 5,
TestElastiCachePlugin_CacheClusterPagination(emulator/elasticache_plugin_test.go) is not quietly relaxed. It asserted only that page one carried a<Marker>, then fetched page two with a hand-written"Marker": "2"and ended with_ = body— it never asserted anything about page two's contents, which is precisely why it passed against a cursor that dropped a record. It now walks theMarkerpage one actually returned and asserts page two's records and that they do not repeat page one's.Tests
emulator/query_marker_pagination_test.go, wire-level only (no direct state writes):Markerequalsbase64("mk-db-1")and the last page carries none;mk-db-2;MaxRecords=2: the full last page carries noMarker;"2","mk-db-1!") answers 400 /InvalidParameterValueon both RDS describes and on ElastiCache;DescribeDBClustersandDescribeCacheClusterspage every record exactly once.Not in scope
MaxRecordsis left alone deliberately: substrate honours a value outside the documented 20–100 range and silently rewrites an unusable one. That is #913 — folding a page-size change into a page-contents change would have made the two indistinguishable in this diff and in any test that failed.Verification
The nine-command gate is green, e2e included. Coverage 84.1% emulator / 83.6% total — baseline held.