Repository navigation
fix(persistence): refuse a chained search whose hop passes a ceiling - #2949
Open
angela-helios wants to merge 1 commit into
Open
angela-helios wants to merge 1 commit into
angela-helios wants to merge 1 commit into
Conversation
The chain resolver drained every hop of a chained or _has search into memory before turning it into an _id filter, with no ceiling. A hop now stops at 300,000 ids (100,000 whole resources on the full-page path) and fails with TooManyResults, answered 422, instead of growing without bound. Closes #2948
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This branch has not been deployed
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 #2948
Summary
The chain resolver drained each hop of a chained or
_hassearch whole into memory before turning it into an_idfilter. On a large tenant, onePatient?_has:Observation:subject:status=finalheld every matching Observation id, and insearch_all_pagesevery whole resource.Each hop now has a ceiling, checked after every page:
search_all_ids: 300,000 ids (MAX_HOP_IDS), the ceiling MongoDB already puts on its result id sets;search_all_pages: 100,000 resources (MAX_HOP_RESOURCES), lower because it keeps whole resources.A hop that passes its ceiling fails with
SearchError::TooManyResults { count, max }, which the REST search handler already maps to422. The hop is not truncated into a wrong answer. A test-only task-local lowers the ceiling, as MongoDB'swith_result_id_capdoes.Tests
chain_resolver::tests::a_hop_past_its_ceiling_is_refused_not_truncatedruns on both drain paths, with the ceiling lowered to 3:TooManyResults { count: 4, max: 3 };With the ceiling disabled, the four are drained (
Ok(["a","b","c","d"])) and the test fails.The existing 33 resolver tests pass, including the 2101-row multi-page drain. Clippy on
helios-persistence --lib --testsis clean.