Repository navigation
Cherry pick #117351 to 26.8: Check allow_statistics only when validating a mutation, not when running it - #125655
Merged
robot-ch-test-poll merged 11 commits intoOct 14, 2026
Merged
Conversation
…nning it `ALTER TABLE ... MATERIALIZE STATISTICS` (and `DROP STATISTICS`) was validated with the submitting session's `allow_statistics` and then checked again during execution, where the background context reads the server-default profile rather than that session. With a profile that disables statistics and the same session-level opt-in `ADD STATISTICS` honours, the statement was accepted and then failed forever: `mutations_sync = 1` returned `UNFINISHED`, and without it the mutation sat in `system.mutations` retrying and wedging the table's mutation queue until a manual `KILL MUTATION`. The setting gates the DDL - whether statistics may be declared on a table - so only the submitting session's value is meaningful, and the check belongs to validation alone. Background merges materialize the declared statistics regardless of the setting, so refusing the explicit verb at execution time protected nothing. Closes: #115448
…tistics-session-gate
…tions Address the review finding on the previous commit: moving the `MATERIALIZE STATISTICS` gate into the `dry_run` pass of `MutationsInterpreter::prepare` left it bypassable, because `MATERIALIZE STATISTICS` parses into a `MutationCommands` segment only and the dry-run `MutationsInterpreter` is the sole pass over those - it is skipped entirely when the user sets `validate_mutation_query = 0`. Apply the gate exactly once instead, unconditionally at submission time in `InterpreterAlterQuery`, next to the other always-on mutation validation, and drop both execution-time checks from `MutationsInterpreter`. `ADD/DROP/MODIFY STATISTICS` keep their own always-on gate in `AlterCommands::validate`. The `validate_mutation_query = 0` bypass turned out to exist on master too: with `allow_statistics = 0` in the server profile, `ALTER TABLE ... MATERIALIZE STATISTICS a SETTINGS validate_mutation_query = 0` is accepted and runs, so this closes a real hole rather than one the previous commit introduced. Tests: the stateless test is renumbered to `05175` after the master merge (`05085` is taken) and extended with the `validate_mutation_query = 0` case. The half of the reproducer that needs a server profile - which a stateless test cannot set - moves to a new integration test `test_statistics_mutation_session_gate`; both of its cases fail on master and pass with this change, verified locally. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…tistics-session-gate # Conflicts: # src/Interpreters/InterpreterAlterQuery.cpp
…e the anonymous namespace Fixes the `readability-static-definition-in-anonymous-namespace` clang-tidy error that failed `Build (arm_tidy)`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117351&sha=52aadbd9fa57776566945813040202829c18cd11&name_0=PR&name_1=Build%20%28arm_tidy%29 PR: #117351 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…tistics-session-gate Conflicts with the removal of `validate_mutation_query` on master: keep `checkStatisticsMutationsAreAllowed` and master's always-on validation, and reword the helper's comment, which referred to the now obsolete setting.
… tests The setting is obsolete on master and has no effect, so the cases only repeated the ones above them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…-session-gate Check `allow_statistics` only when validating a mutation, not when running it
Resolve conflicts: keep both `allow_statistics` and `validate_mutation_query` declarations in `InterpreterAlterQuery`, keep 26.8's `runCommandSegments` signature (no `no_ddl_lock`), call `checkStatisticsMutationsAreAllowed` before the 26.8 non-determinism/validation block, and drop the now-unused `allow_statistics` declaration from `MutationsInterpreter`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #117351
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