Skip to content

Cherry pick #131636 to 26.3: Skip a setting value from the server's Hello that this version rejects instead of failing the connection - #132959

Merged
robot-ch-test-poll2 merged 4 commits into
backport/26.3/131636from
cherrypick/26.3/131636
Nov 22, 2026
Merged

robot-ch-test-poll2 merged 4 commits into
backport/26.3/131636from
cherrypick/26.3/131636

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #131636

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.

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:

  • 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

groeneai and others added 3 commits November 14, 2026 12:50
Since #131269 a `Seconds` setting rejects a negative or overflowing value,
while every supported older release accepts and stores one, and its
`TCPHandler::sendHello` sends the user's changed settings in `Hello`.
`Connection::receiveHello` read them with the same strict `BaseSettings::read`
the server uses for a client's query settings, so a client or an initiator
with #131269 could not connect at all to an older server whose user or
profile has e.g. `max_execution_time = -1` (`Code: 36 ... cannot be negative`).
An unknown non-important setting from the server was already only a warning.

`BaseSettings::read` gets an opt-in `skip_invalid_values`: in the
`STRINGS_WITH_FLAGS` branch the value string is read first, and if parsing
it throws `BAD_ARGUMENTS` or a parse error (`isParseError`, the same
classification `insertPostgreSQLValue` uses) for a non-important setting,
the field is reset to its default and a warning is logged. The reset is
needed because `SettingFieldNonZeroUInt64::parseFromString` assigns before it
throws. Any other exception, and an `IMPORTANT` setting (the rule the
unknown-setting branch already applies), still fail the read. Only
`Connection::receiveHello` opts in: the settings in `Hello` are advisory for
the client (the server applies its own profile to every query), while the
server's read of a client's settings must keep rejecting `-1` (#131194).

Tests: a gtest for the tolerant read (a rejected `Seconds` value, a zero
`NonZeroUInt64`, an unparsable `Bool`, a valid setting after them, the strict
default, an `IMPORTANT` flag, and an unknown enum name (`load_balancing`),
which still fails the tolerant read), and a `test_backward_compatibility` case
with a 25.3 node: a user with `max_execution_time = -1`, reached by the tested
client and by a tested `remote()` initiator. The test uses
`query_and_get_answer_with_error` because the client prints the warning on
stderr.

Closes #131506
Related #131269, #131194

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…skip-invalid-values

Resolve the conflicts with #131099, which removed `SettingsWriteFormat`:
`BaseSettings::read` and `Settings::read` now take only `skip_invalid_values`,
and the tolerant parse applies to the single remaining string path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lid-values

Skip a setting value from the server's Hello that this version rejects instead of failing the connection
@robot-ch-test-poll robot-ch-test-poll 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 pr-bugfix Pull request with bugfix, not backported by default labels Nov 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

This cherry-pick would not fix 26.3, so I did not resolve it. On 26.3 SettingFieldSeconds::parseFromString does not validate the value (#112757 is not on 26.3), so the Hello read already accepts max_execution_time = -1, and the 26.3 client fails later, when it applies the server's settings.

Measured against a 25.3 server whose user has max_execution_time = -1:

So this PR can be closed. The 26.3 client failure comes from the 26.3 backport of #131269 (#131779; the 26.3.63.123 client works against the same server) and would need a different change on 26.3.

Conflicts in `src/Client/Connection.cpp`, `src/Core/BaseSettings.h`,
`src/Core/Settings.cpp`, `src/Core/Settings.h` and
`src/Core/tests/gtest_settings.cpp` are resolved by taking the 26.3 side and
re-applying the change of #131636 on top of the 26.3 API
(`read(in, format, skip_invalid_values)`, `isParseError` from
`Processors/Formats/IRowInputFormat.h`).

Adaptation for 26.3: here `SettingFieldSeconds::parseFromString` does not
validate the value (#112757 is not on 26.3), so reading `max_execution_time = -1`
from the server's `Hello` succeeds and the client fails later, when it applies
the value as a `Field`. With `skip_invalid_values`, `BaseSettings::read` now
also re-assigns the parsed value as a `Field`, so such a value is skipped with
a warning, as on master. The strict read (the server side) is unchanged.
The gtest is adapted accordingly; master-only gtests are not carried over.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, your analysis is right: on 26.3 SettingFieldSeconds::parseFromString does not validate, so the plain cherry-pick would be a no-op for the client. Rather than closing, I resolved the conflicts with a small 26.3-specific adaptation (ab83feb):

  • with skip_invalid_values (only Connection::receiveHello opts in), BaseSettings::read re-assigns the parsed value as a Field — the same operation the client performs later when it applies settings_from_server. So max_execution_time = -1 from an older server is rejected at that point, skipped with the warning, and never reaches Context::applySettingChange;
  • the strict read (server side) is unchanged, so this does not alter what the 26.3 server accepts;
  • the gtest is adapted: the strict read of -1 is not expected to fail on 26.3, and it additionally checks that every change that was read can be applied as a Field.

Verification here is limited to -fsyntax-only checks of BaseSettings.cpp, Settings.cpp, Connection.cpp and gtest_settings.cpp against the 26.3 tree; the gtest and test_backward_compatibility were not run locally and will run in the CI of the backport PR. If you can re-run your measurement against the 25.3 server with this head, please post the result. Whether to take this 26.3-specific variant or close the backport remains a maintainer's decision.

@robot-ch-test-poll2
robot-ch-test-poll2 merged commit a8591c8 into backport/26.3/131636 Nov 22, 2026
2 checks passed
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/26.3/131636 branch November 22, 2026 16:41
@groeneai

Copy link
Copy Markdown
Collaborator

I re-ran the measurement at ab83feb0f7f6, which has the same tree as #133563. Setup: a Debug build with clang-21, a 25.3.14.14 server, and a user created with SETTINGS max_execution_time = -1.

  • clickhouse client prints Cannot parse the value of setting `max_execution_time`, skipping it: A setting's value in seconds cannot be negative. Got -1 and returns 1. The official 26.3.69.4 client still fails against the same server with Code: 36 ... in attempt to set the value of setting 'max_execution_time' to -1.
  • A remote() initiator (clickhouse local) returns 1.
  • Control, a user with max_execution_time = 7: the client returns 1 with no warning, and remote() returns 1.
  • unit_tests_dbms --gtest_filter='Settings*:SettingMySQL*:SettingsCompatibility*:BaseSettings*:SettingField*': 9/9 passed, including SkipInvalidValuesKeepsTheDefaultsAndReadsTheRest.

One problem with #133563: the new case in test_backward_compatibility cannot pass on 26.3. There node1 runs CLICKHOUSE_CI_MIN_TESTED_VERSION = "23.3", while master, 26.8, 26.9 and 26.10 use 25.3. A 23.3 server does not send its settings in Hello, because DBMS_MIN_REVISION_WITH_SERVER_SETTINGS = 54474 first shipped in 24.12. Against a 23.3.22.3 server with the same user, this build returns 1 with an empty stderr, so assert "Cannot parse the value of setting `max_execution_time`, skipping it" in err fails. The official 26.3.69.4 client also returns 1 there, so on 26.3 the case cannot show the problem at all. I would leave it out of the 26.3 backport. The gtest covers the change there.

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-bugfix Pull request with bugfix, not backported by default 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.

4 participants