Skip to content

Cherry pick #131269 to 26.8: Reject negative and overflowing values of Seconds settings - #131470

Merged
robot-clickhouse-ci-1 merged 6 commits into
backport/26.8/131269from
cherrypick/26.8/131269
Nov 15, 2026
Merged

robot-clickhouse-ci-1 merged 6 commits into
backport/26.8/131269from
cherrypick/26.8/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.8.

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

Copy link
Copy Markdown
Collaborator

The conflicts are all next to code that 26.8 does not have: neighbouring gtests in gtest_settings.cpp, the test_async_insert_flush_timeout_is_clamped case of test_prometheus_protocols/test_async_insert.py (#118040) and the Log/File part of 04327_wait_timeout_chrono_overflow (#117974). None of those PRs is labelled for 26.8, so the robot's retry cannot resolve this one. I kept the 26.8 side there and applied only this PR's change: the SettingsFields.cpp hunk, both gtest additions (plus the BAD_ARGUMENTS declaration that 26.8's gtest_settings.cpp lacks), and 04327 loses its one negative lock_acquire_timeout query. test_async_insert.py stays as it is, because the case this PR removes is not on 26.8, and 04058_check_constraints_for_profiles (#119472) does not exist on 26.8.

On the 26.8 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.8.34.13 accepts both values and stores the second one as -9223372036854.775.

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

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

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks @groeneai — I verified your merge 4534110eedc0 (parents: this PR's head 70047a956b4b and backport/26.8/131269 621b0baa542e, no leftover conflict markers, diff against the backport branch limited to the 9 files of #131269 that exist on 26.8) and pushed it to cherrypick/26.8/131269 as a fast-forward.

@robot-clickhouse-ci-1
robot-clickhouse-ci-1 merged commit 061d805 into backport/26.8/131269 Nov 15, 2026
2 checks passed
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 deleted the cherrypick/26.8/131269 branch November 15, 2026 11:29
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