Repository navigation
Cherry pick #131269 to 26.3: Reject negative and overflowing values of Seconds settings - #131469
Conversation
`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
Resolve the conflicts of #131269 for 26.3. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The only code conflict is the type name in On the 26.3 tree (clang-21, debug) the existing settings gtests pass, and I cannot push to |
|
🕵 Applied @groeneai's resolution as a fast-forward ( |
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-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