fix(sources): reserve the engine's cursor/pageSize bind names from run-time parameters - #253
Merged
Merged
Conversation
…n-time parameters Run-time (execution) parameters were bound BEFORE the engine's own @cursor and @pageSize, and AddParameter skips a name that is already bound — so a caller passing a parameter named "cursor" pinned the keyset cursor to their value for every page. A standard keyset query (WHERE (@cursor IS NULL OR Id > @cursor) ORDER BY Id) then returns the same first page forever: the runner's page loop only stops on HasMore=false, so the run never terminates and keeps appending to its temp file. Reachable from one report-run request. Bind the engine's reserved names first, so the existing first-wins rule protects them; run-time parameters still beat the source's static ones for every other name. Applied to both the read and the row-count query. Covered by a Sqlite integration test verified to fail without the fix (page 2 repeated page 1).
|
|
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.



What
Run-time (execution) parameters were bound before the engine's own
@cursorand@pageSize, andAddParameterdeliberately keeps whichever name was bound first (that's how "run-time beats the author's static parameter" works, WP4). Nothing reserved the engine's own names.So a report run supplying a parameter named
cursorpinned it for every page:A standard keyset query —
WHERE (@cursor IS NULL OR Id > @cursor) ORDER BY Id— then returns the same first page forever. The runner's page loop only stops when the source reports no more data (ReportRunnerwhile(true)+if (!batch.HasMore) break), andhasMorestays true, so the run never terminates and keeps appending to its staging file. Constant memory holds; disk does not.A milder variant:
{"parameters":{"pageSize":1}}makesrecords.Count != _pageSizeon the first page, so the report silently completes with 1 row and statusCompleted.Fix
Bind the engine's reserved names first, so the existing first-wins rule protects them. Run-time parameters still override the source's static ones for every other name — that behaviour is unchanged. Applied to both
ReadBatchAsyncand the row-count query (CountAsync), which had the same ordering.SqlKeysetSource(SQL Server) andAdoNamedKeysetSourceboth delegate toAdoKeysetSource, so every relational provider is covered by the one change.Verification
A_run_time_parameter_cannot_take_over_the_engine_cursor: reads two pages while passing a hostilecursorparameter and asserts page 2 moves past page 1.should be greater than).Found by a bug hunt over the HTTP API layer.