Skip to content

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 into
backport/26.4/104705from
cherrypick/26.4/104705
May 15, 2026
Merged

robot-ch-test-poll2 merged 8 commits into
backport/26.4/104705from
cherrypick/26.4/104705

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

fm4v and others added 8 commits May 12, 2026 15:07
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
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels May 15, 2026
@robot-ch-test-poll2
robot-ch-test-poll2 merged commit f4c19fc into backport/26.4/104705 May 15, 2026
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/26.4/104705 branch May 15, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants