Repository navigation
fix(#1229): a published filter selects what the page is cut from - #1250
Merged
Merged
Conversation
listSchedules read its three filters in three places relative to the cut:
ScheduleGroup chose which name index to load and NamePrefix filtered that index,
both ahead of it, but State ran inside the render loop — on the records the page
had already selected. So a state-filtered request was answered MaxResults
schedules minus however many of that page failed the filter, while the NextToken
alongside had been computed from the unfiltered listing.
API_ListSchedules publishes State in the same URI-parameter list as the other two
and in the same words ("If specified, only lists the schedules whose current
state matches the given filter."), and the cursor is the ordinary "Indicates
whether there are additional results to retrieve". Nothing on the page says a
page may be short. ?State=ENABLED&MaxResults=20 over a group of 40 half of which
are DISABLED answered fewer than 20 with a cursor set, where AWS answers 20; and
a page all of whose schedules failed the filter answered an empty Schedules array
alongside a NextToken, which a caller that stops at an empty list reads as
"nothing matches".
All three filters now run before the cut, so a page carries min(MaxResults,
remaining matches). The cost is a state.Get per schedule in the group per call,
because State lives in the record and not in the name index — taken deliberately
over copying State into the index and leaving UpdateSchedule two places to write
it, which is the class #756 is about.
A name the index holds with no record behind it, and a record that will not
decode, are still skipped: those are store inconsistencies rather than published
filters, and no request a caller can send produces either. What changed is that
skipping one can no longer shorten a page.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
listSchedulesread its three filters in three different places relative to the cut.ScheduleGroupchose which name index to load and
NamePrefixfiltered that index — both ahead of the cut — butStatewas applied inside the render loop, on the records the page had already selected. So astate-filtered request was answered
MaxResultsschedules minus however many of that page failed thefilter, while the
NextTokenalongside had been computed from the unfiltered listing.Found while converting this operation's token for #1086 and deliberately left out of PR #1228, which is
why
scheduler_pagination.gocarried it as "not fixed here". That bullet is now the fix's owncross-reference rather than a standing divergence.
Why it is a divergence
API_ListSchedulespublishesStatein the same URI-parameter list as the other two filters and inthe same words:
So it is a filter on the listing, and the listing is what a page is cut from. The response member is
the ordinary cursor — "Indicates whether there are additional results to retrieve. If the value is
null, there are no more results." — and nothing on the page says a page may be shorter than the
MaxResultsit was asked for.Two observations changed, the second worse:
?State=ENABLED&MaxResults=20over a group of 40 half of which areDISABLEDanswered fewer than 20enabled schedules with a cursor set, where AWS answers 20.
{"Schedules":[],"NextToken":"…"}withmatches still to come. A caller that stops at an empty list — several SDK paginator idioms do — reads
that as "the filter matched nothing". AWS can produce the shape too, but from server-side scan limits,
never from applying a filter it publishes.
The reading taken, and the one refused
Filtering ahead of the cut means loading every record in the group per call rather than one page's
worth, because
Statelives in the record and not in the name index. That is the deliberate choice —issue reading 1. The alternative, carrying
Statein the name index so the filter stays index-only,would duplicate a field of the record into an index and leave
UpdateSchedulewith two places to writeit, which is the class #756 exists for. A
state.Getper schedule in a group is not a cost worth thatin an in-process emulator.
What is unchanged, and said so
Statefilter and replayedwithout one indexes into a different listing. Already true of
NamePrefix, and already recorded inscheduler_pagination.goas a property of every offset paginator in the tree: the token carries anoffset and nothing else. Not widened, not narrowed.
skipped (acceptance criterion 4). They are store inconsistencies rather than published filters —
no request a caller can send produces either, and the page publishes no code for substrate's own
index and records disagreeing, so a refusal would be inventing one. What changed is that skipping one
can no longer shorten a page: it shortens the listing being cut from, exactly as a filter does.
MaxResultsabove the published maximum of 100 still clamps rather than being refused, with zeroor below ignored in favor of substrate's own default of 20. Still recorded as not fixed here.
Verification
emulator/scheduler_list_filters_test.gobuilds its group through realCreateSchedulecalls(cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765) and asserts over the wire: twelve schedules alternating
ENABLED/DISABLED, so every prefixof the unfiltered listing contains both. A full first page, a resumption that reaches all six matches
in two pages, a
MaxResults=1walk asserting no page carries a cursor without a match, theunfiltered listing unchanged,
Statecomposing withNamePrefix, and a second test keepingScheduleGroupscoping honest.schedules), the resumption (wrong names, three pages), and the empty-page-with-cursor rule.
make lint→ 0 issues.make test(race) → green.make docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check→ green, 330 fields.docs/services.mdgains a section for the fix, theListSchedulesrow records the filter order, andPR #1228's "left as they were" paragraph now says which half was fixed.
Closes #1229.