Repository navigation
Cherry pick #104705 to 26.4: Add defer_partition_pruning_after_final setting to gate the 26.3 FINAL pruning regression - #105025
Merged
robot-ch-test-poll2 merged 8 commits intoMay 15, 2026
Conversation
PR #98242 (commit `ebc5cb49baa594b87f4631850ae9902424414113`, landed in 26.3) disabled partition pruning unconditionally for any `FINAL` query whose partition-key columns are not part of the sorting key. The intent was correctness: a `FINAL` merge may need to deduplicate same-primary-key rows that live in different partitions, so partition pruning would silently drop input rows. In practice this hits event-log workloads hard. Their tables are partitioned by the event timestamp, which is set once at insert time and never changes — same-PK rows cannot span partitions. Reported wall-clock and memory regressions on real customer queries are around 6× and 4.4× respectively (see #104263). This commit makes the deferral opt-out via a new setting `defer_partition_pruning_after_final`: - 1 (default): preserves the 26.3+ correctness behavior. - 0: restores pre-26.3 partition pruning before FINAL. Safe only when the user can assert same-PK rows cannot exist in different partitions. The setting follows the same pattern as `apply_row_policy_after_final` and `apply_prewhere_after_final`. `compatibility = '26.2'` flips it to 0 via `SettingsChangesHistory`. A stateless regression test covers both the issue's reproducer (pruning works under opt-out) and the den-crane pathological case (same PK in two partitions with reversed versions — default deduplicates correctly across partitions, opt-out trusts the user's assertion and prunes first). Issue: #104263
26.3 is the version where the silent behavior change happened (PR #98242). Putting the entry under 26.3 makes `compatibility = '26.2'` correctly revert the setting to 0 (pre-regression behavior); `compatibility = '26.3'+` keeps the post-regression default of 1.
The stateless check `02995_new_settings_history` requires every newly added setting to appear in `SettingsChangesHistory.cpp` under a version block greater than the baseline (currently 26.4). The meaningful entry for `defer_partition_pruning_after_final` lives under 26.3 so that `compatibility = '26.2'` reverts it correctly, but the test only inspects the existence of a name match in version > 26.4. Add a no-op `true -> true` entry under the 26.5 block to satisfy the check while preserving the compatibility semantics — the 26.3 entry remains the one the compatibility mechanism acts on.
…ine instead The previous commit added a no-op `true -> true` entry under 26.5 only to satisfy the `02995_new_settings_history` check. Doing so muddied the compatibility semantics: the 26.3 entry is the one the rollback mechanism should act on, and having a duplicate name in 26.5 risked confusing future readers. Drop the 26.5 entry and instead add `defer_partition_pruning_after_final` to the test's 26.4.1 baseline TSV so the check no longer flags it as a "new" setting without a `> 26.4` history entry. The 26.3 entry remains the single source of truth for compatibility handling.
The Upgrade check (tests/docker_scripts/upgrade_runner.sh) uses the previous
release binary as the comparison floor and requires every new setting to have
a history entry strictly above that floor — currently > 26.4. A 26.3 entry
alone is below that floor and fails the check, regardless of how the static
TSV baseline is shaped.
Re-add the no-op 26.5 entry (`true -> true`) so the Upgrade check accepts the
new name. The 26.3 entry remains the one the compatibility mechanism acts on:
- `compatibility = '26.2'` -> walks the 26.3 entry, reverts to 0 (correct).
- `compatibility = '26.3'`/`'26.4'` -> 26.3 entry not in scope; 26.5 entry
is a no-op; setting stays at default 1 (matches what those versions
actually did).
Also drop the 02995 baseline TSV addition from the prior commit — the 26.5
history entry alone is sufficient for both that test and the Upgrade check.
…g-after-final Add `defer_partition_pruning_after_final` setting to gate the 26.3 FINAL pruning regression
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.
Original pull-request #104705
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.
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