Repository navigation
Reject timespan setting (milliseconds/seconds) values that overflow Int64 microseconds - #112757
Conversation
|
Workflow [PR], commit [5d1aed1] Summary: ❌
AI ReviewSummaryThis PR makes PR Metadata
Findings❌ Blockers
Final VerdictNeeds changes. The overflow fix itself looks sound, but I would not approve it without a compatibility or migration path for already-persisted oversized |
Algunenano
left a comment
There was a problem hiding this comment.
Makes sense to me. Another way to handle it would be via SettingsQuirks, but that's less clean
|
Quirks are for different things, we can clamp values instead here, but it will be nice to avoid this and simply throw instead of accepting invalid values |
| Int64 SettingFieldTimespan<unit_>::microsecondsFromUnits(UInt64 units) | ||
| { | ||
| constexpr std::string_view unit_name = unit == SettingFieldTimespanUnit::Millisecond ? "milliseconds" : "seconds"; | ||
| if (units > static_cast<UInt64>(std::numeric_limits<Int64>::max() / static_cast<Int64>(microseconds_per_unit))) |
There was a problem hiding this comment.
This changes the contract for every Seconds/Milliseconds setting, including persisted profile/config values and legacy binary settings from older clients, but there is still no compatibility path for upgraded deployments. A node that currently accepts <connection_pool_max_wait_ms>18446744073709551615</connection_pool_max_wait_ms> (storing the wrapped -1 ms value) will start throwing BAD_ARGUMENTS during settings parsing after this PR. For backward-incompatible validation on existing settings we normally either gate the new behavior behind a setting / SettingsChangesHistory.cpp entry or scope it so old persisted values keep loading.
There was a problem hiding this comment.
This is the intention for now.
375435c to
204d5da
Compare
|
UPD: I am not sure it was it, since part of the log is missing, and the last entries are from runned tests, will rebase |
…nt64 microseconds The `UInt64 -> microseconds` conversion multiplied by the unit factor unchecked, wrapping mod 2^64: `SET connection_pool_max_wait_ms = 2^61` silently stored 0, and `UInt64` max stored -1 ms. Every integer producer (`Field`/`SET`, `parseFromString`, `readBinary`) now throws `BAD_ARGUMENTS`, the same bound the `Float64` path enforces via `float64AsSecondsToTimespan`. `SettingFieldSeconds::parseFromString` had a second bug, an out-of-range `Float64`-to-`Int64` cast (UB) for values like 1e30; it now goes through `float64AsSecondsToTimespan` like the `Field` path. Refs: ClickHouse#106961 Co-Authored-By: Claude Fable 5 <[email protected]>
204d5da to
5d1aed1
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 42/43 (97.67%) · Uncovered code |
619adf6
ClickHouse#112757 made SettingFieldTimespan reject millisecond values that overflow Int64 microseconds, so a configured value can no longer wrap negative in storage. The negative and unsigned-huge cases are still worth pinning because several Keeper sites hold the count in an unsigned type, so the comments now state that invariant instead of the storage path. Co-Authored-By: Claude Fable 5 <[email protected]>
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]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reject timespan setting (milliseconds/seconds) values that overflow Int64 microseconds
Refs: #106961
Version info
26.8.1.647(included in26.8and later)