Skip to content

Fix SettingsConstraints erasing explicit settings before compatibility applies#97078

Merged
rienath merged 3 commits intomasterfrom
fix-settings
Mar 2, 2026
Merged

Fix SettingsConstraints erasing explicit settings before compatibility applies#97078
rienath merged 3 commits intomasterfrom
fix-settings

Conversation

@rienath
Copy link
Member

@rienath rienath commented Feb 16, 2026

We erased settings from the changes vector when their value matches the current server value (as an optimization to skip constraint checks for unchanged values). This is wrong when the same batch contains a compatibility setting. The compatibility mechanism resets settings to historical defaults, which can change the baseline after the constraints check. Any erased setting is then lost and never re-applied.

Example: server has use_skip_indexes_if_final=1 (default since 25.6). Client sends compatibility=24.12&use_skip_indexes_if_final=1. The constraints check sees 1==1, erases it. Then compatibility=24.12 reverts the setting to 0. The explicit =1 is gone.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix a bug where explicit settings sent alongside compatibility in the same request could be silently ignored when their value matched the server default.

@rienath rienath requested a review from Copilot February 16, 2026 14:56
@clickhouse-gh
Copy link
Contributor

clickhouse-gh bot commented Feb 16, 2026

Workflow [PR], commit [998925b]

Summary:

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Feb 16, 2026

This comment was marked as off-topic.

@novikd novikd self-assigned this Feb 16, 2026
The previous commit removed the 'skip if unchanged' optimisation entirely, which broke readonly mode validation and settings change tracking. This fix takes a more targeted approach: only skip the optimisation when compatibility is present in the batch.
Copy link
Member

@novikd novikd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, LGTM

# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh

QUERY_SKIP="SELECT value FROM system.settings WHERE name = 'use_skip_indexes_if_final'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test can be done as a .sql file. It is a preferable option, because the fuzzer can use queries from .sql files, but not from bash scripts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We specifically want to test HTTP URL query parameters. I don't think it is possible to achieve through .sql

Comment on lines +220 to +228
bool has_compatibility = false;
for (const auto & change : changes)
{
if (change.name == "compatibility")
{
return !checkImpl(current_settings, change, THROW_ON_VIOLATION, source);
});
has_compatibility = true;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool has_compatibility = false;
for (const auto & change : changes)
{
if (change.name == "compatibility")
{
return !checkImpl(current_settings, change, THROW_ON_VIOLATION, source);
});
has_compatibility = true;
break;
}
}
bool has_compatibility = changes.tryGet("compatibility") != nullptr;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is much more elegant

@rienath rienath added this pull request to the merge queue Mar 2, 2026
Merged via the queue into master with commit 28cd79a Mar 2, 2026
289 of 292 checks passed
@rienath rienath deleted the fix-settings branch March 2, 2026 12:54
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 2, 2026
@alexey-milovidov
Copy link
Member

It broke the CI, reverting here: #98515

@rienath
Copy link
Member Author

rienath commented Mar 2, 2026

According to RCA, my PR is fine. We hit LOG_WARNING here because of randomised settings with compatibility, which now works correctly thanks to the fix and gets us to the warning. Here is the fix for that #98519

@alexey-milovidov
Copy link
Member

On one side, yes, but anything that breaks our CI is not right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants