Repository navigation
Cherry pick #130148 to 26.10: Do not consult the query condition cache under a masking policy - #133169
Conversation
A masking policy reaches a MergeTree read as a synthetic on-the-fly UPDATE that MergeTreeData::getAlterConversionsForPart appends to the part's AlterConversions. It is not part of the mutations snapshot, and it does not change the filter DAG the condition hash is derived from. So the consult gate in filterPartsByQueryConditionCache (which declines only on snapshot state) passes, and a masked read of predicate P reuses entries an unmasked read of P recorded over the raw column values. Those entries can mark granules as non-matching that do match the masked values, so the masked read silently drops rows; in the other direction, the number of granules skipped leaks where raw values match. Decline the consult when the table has an enabled masking policy for the current user, with the same hasEnabledMaskingPolicies idiom the statistics-pruning gate in this file already uses. The write side needs no change: a masked read of a masked column carries on-the-fly mutation steps, so MergeTreeReadTask:: appliesMutationsBeforePrewhere already keeps it from writing entries (the mechanism 03229_query_condition_cache_on_fly_mutations covers), and a read that touches no masked column sees raw values equal to masked ones. Outside the Cloud build hasEnabledMaskingPolicies always returns false, so public behaviour is unchanged. The behavioural test lives in the private repository, where masking policies can be created. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-policy-gate Do not consult the query condition cache under a masking policy
|
The only conflict is in the early return of A syntax-only compile of the resolved file against the 26.10 sources with clang-22 is clean (not a full build). There is no public behavioral test: outside Cloud, I cannot push to |
Original pull-request #130148
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job