Repository navigation
Do not write TopK query condition cache entries from reads with on-fly mutations or patch parts - #122617
Conversation
…y mutations or patch parts A TopK read drops granules based on a threshold derived from the rows of all parts, so a part without mutations of its own could record granules as empty under a threshold tightened by rows that an on-fly mutation or a patch part rewrote in another part. A later read that does not apply them (`apply_mutations_on_fly = 0`, `apply_patch_parts = 0`, or after `KILL MUTATION`) then skipped rows. Closes: #122564
|
Workflow [PR], commit [9028e83] Summary: ✅
AI ReviewSummaryThis PR fixes a real read/write asymmetry in TopK Final Verdict
LLVM Coverage ReportMeasured on commit 9028e83.
Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 31 s compile time in total, 7 of them have a recent master baseline. |
The
__topKFilterPREWHEREof anORDER BY ... LIMITread (cached since #114659) drops granules based on a threshold derived from the rows of all parts in the read. The write paths only guard onappliesMutationsBeforePrewhereof the part being read, so a part without mutations of its own recorded its granules as empty under a threshold tightened by rows that an on-fly mutation or a patch part rewrote in another part. Part names do not change until the mutation is materialized, so a later read that does not apply it (apply_mutations_on_fly = 0,apply_patch_parts = 0, or any read afterKILL MUTATION) consulted the entry and skipped rows.The fix disables query condition cache writes in
ReadFromMergeTree::initializePipelinefor TopK reads whose mutations snapshot has data mutations or patch parts. This mirrors the consult side (filterPartsByQueryConditionCache), which already never reads the cache under such a snapshot. It covers both the TopK-saltedPREWHEREwrite and theWHERE(MarkRangesInfo) carrier.The new test fails on unfixed master (checked with the CI build of
7264abe5d4cfon a local server): all three cases return1000000..1000004instead of1000..1004.Closes: #122564
Related: #114659
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/122617]
Version info
26.10.1.970-master(included in26.10and later)