Fix retry bug in tree model query which ignore the time filter#18179
Open
JackieTien97 wants to merge 4 commits into
Open
Fix retry bug in tree model query which ignore the time filter#18179JackieTien97 wants to merge 4 commits into
JackieTien97 wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #18179 +/- ##
============================================
+ Coverage 42.04% 42.60% +0.56%
Complexity 318 318
============================================
Files 5312 5323 +11
Lines 375102 376815 +1713
Branches 48422 48742 +320
============================================
+ Hits 157693 160548 +2855
+ Misses 217409 216267 -1142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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.



Description
Problem
The first query dispatch may fail for a retryable reason. In the reported case, the DataNode hosting the region leader had reached the upper limit of 1,000 internal connections.
QueryExecutionthen analyzes the same parsed statement again. However, tree-model analysis previously modified parser-owned AST state in place, including extracting the global time predicate fromWHERE. As a result, the retry could analyze a statement different from the original SQL and lose its time filter. Other analysis-time mutations, such as normalized expressions,ORDER BY,LIMIT/OFFSETpushdown, and template-specific rewrites, had the same retry-safety risk.Changes
TreeAnalysisMutationJournalfor tree-model analysis:ORDER BY;QueryExecution:DEVICEandTIMEsort keys forDeviceViewin planning-owned state instead of appending them to the parsedQueryStatement.SHOW DEVICESandCOUNT DEVICESstatements on per-analysis working copies. Internal schema-fetchShowDevicestatements retain their pre-populated traversal state because that state is request input rather than derived analysis data.WHEREexpressions in table-model working copies. This analysis path treats them as read-only, replaces rewritten roots only on the working statement, and avoids a deep-copy cost on normal one-attempt queries.These changes ensure that every retry observes SQL semantics equivalent to the original statement while limiting copying to state that analysis actually needs to modify.
Tests
Added regression unit tests covering:
AND,OR, andNOTpredicates without mutating input expressions;GROUP BY,HAVING,ORDER BY,SELECT INTO,LIMIT/OFFSET,count_time(*), and template analysis;DeviceViewandSortNodeplanning without modifying or accumulating sort keys in the parsed statement;SHOW DEVICESandCOUNT DEVICES;ShowDevicetraversal state.