Skip to content

Cherry pick #131269 to 26.9: Reject negative and overflowing values of Seconds settings - #131471

Merged
robot-ch-test-poll4 merged 6 commits into
backport/26.9/131269from
cherrypick/26.9/131269
Nov 15, 2026
Merged

robot-ch-test-poll4 merged 6 commits into
backport/26.9/131269from
cherrypick/26.9/131269

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Original pull-request #131269

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 5 commits November 13, 2026 09:35
`float64AsSecondsToTimespan` converts every user value of a `Seconds`
setting (SET, query SETTINGS, profiles and constraint bounds, config files,
HTTP parameters, the native protocol) into Int64 microseconds.

It accepted negative values, which every consumer reads as "no limit" and
which compare below any MAX settings constraint, so a constrained user could
run `SET max_execution_time = -1` and escape the administrator's limit.
Negatives were allowed in #37187 only because `drain_timeout` gave `-1` a
meaning; that setting is obsolete and none of the 40 live `Seconds`
settings documents a negative value. `Milliseconds` settings already reject
negatives.

Its range check compared the product with `Int64::max()` converted to
Float64, which rounds up to 2^63, so `9223372036854.775` (product exactly
2^63) passed and the `static_cast<Int64>` overflowed: UBSan aborts, and a
release build stores INT64_MIN, i.e. a negative timeout again. Use
`accurate::greaterOp`, as `fieldToNumberSettingValue` does.

Tests: a MAX-constraint case in 04058, the overflow value in 03000, the
negative values of 02294 move to the error group, and gtests for the string
parse and the native STRINGS_WITH_FLAGS wire. 02466 drops the obsolete
`drain_timeout=-1` and 04327 its negative `lock_acquire_timeout` lines,
which are now rejected.

Closes #131194

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The six-line header described the `d * 1000000 < min()` branch of
`float64AsSecondsToTimespan`, which no longer exists: negative values are
now rejected before the range check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
clang-tidy (`clang-analyzer-optin.core.EnumCastOutOfRange`, an error under
`WarningsAsErrors`) rejects `static_cast<Flags>(0)` because 0 is not an
enumerator of `BaseSettingsHelpers::Flags`, which broke `Build (arm_tidy)`.
Use value-initialization, as `BaseSettings::write` does; the bytes written
are the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…theus test

`test_async_insert_flush_timeout_is_clamped` sent
`wait_for_async_insert_timeout=-10000000000` and expected the wait clamp to
answer 503. A negative `Seconds` value is now rejected when the URL settings
are applied (400, `BAD_ARGUMENTS`), so the request never reaches the wait and
nothing is queued: the case is gone and two rows arrive instead of three. The
positive overflow case still covers the clamp.

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

Reject negative and overflowing values of `Seconds` settings
@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 Nov 13, 2026
Resolve the conflicts of #131269 for 26.9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

The only conflict is 04058_check_constraints_for_profiles, which this PR extends and 26.9 does not have (it came with #119472, which was not backported). I left it out; every other file applies as on master.

On the 26.9 tree (clang-22, debug) the settings gtests pass, the two new ones included, and 02294_decimal_second_errors, 02466_distributed_query_profiler, 03000_too_big_max_execution_time_setting, 04201_too_negative_max_execution_time_setting and 04327_wait_timeout_chrono_overflow pass 10 of 10 with random settings. For a user whose profile has max_execution_time = 5 MAX 60, SET max_execution_time = -1 and SET max_execution_time = 9223372036854.775 now fail with BAD_ARGUMENTS, and -1 is rejected the same way as a client option and as an HTTP parameter. The official 26.9.25.15 accepts both values and stores the second one as -9223372036854.775.

I cannot push to cherrypick/26.9/131269. The merge is on my fork, its first parent is this PR's head 70047a956b4b and its second is backport/26.9/131269, so applying it is a fast-forward:

git fetch https://github.com/groeneai/ClickHouse.git groeneai/resolve-26.9-cherrypick-131269
git push origin FETCH_HEAD:cherrypick/26.9/131269

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks, I checked the merge and pushed it as a fast-forward: cherrypick/26.9/131269 is now 90de1694cfc0. Its parents are the previous PR head 70047a956b4b and backport/26.9/131269 1261ec0d90b3. Compared with the backport branch, it changes only the original PR's files. 04058_check_constraints_for_profiles is left out because 26.9 does not have that test.

@robot-ch-test-poll4
robot-ch-test-poll4 merged commit 2fce14a into backport/26.9/131269 Nov 15, 2026
2 checks passed
@robot-ch-test-poll4
robot-ch-test-poll4 deleted the cherrypick/26.9/131269 branch November 15, 2026 11:18
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.

4 participants