Repository navigation
Accept only time zone names that the built-in database has - #120288
Conversation
`isSupportedTimeZoneName` was a deny-list of two prefixes, `libc:` and `Fixed/`, so acceptance of every other name was delegated to whatever `cctz`'s filesystem fallback could open. That set is not the time zone database. `cctz` resolves a name as a path under the time zone database directory, and with a `file:` prefix as an arbitrary path, so one zone has unboundedly many names: `Europe/./Amsterdam`, `Europe//Amsterdam`, `file:UTC`, `file:/usr/share/zoneinfo/UTC`, and any number of repetitions of `./` and `/`. None of them is in `system.time_zones`, and every distinct name that gets loaded permanently costs ~4.6 MiB in the `DateLUT` cache, which never evicts anything because callers keep bare references into it. So the cache that the two previous fixes were bounding was still unbounded, reachable through `toDateTime(x, '<name>')`, the `session_timezone` setting, binary type decoding, or the time zone of an Arrow or ORC timestamp column. Peak RSS of `clickhouse-local`, before this change: 20 uses of `Europe/Amsterdam` 182 MB 20 distinct `./`-padded spellings of `Europe/Amsterdam` 303 MB 100 distinct `./`-padded spellings of `Europe/Amsterdam` 683 MB 100 distinct `file:` spellings of `UTC` 679 MB `file:` was also a way to read a file outside the time zone database directory, which is exactly what the `CheckTimeZoneName` guard vendored into `contrib/cctz` exists to prevent: a TZif file copied anywhere on the filesystem loaded and answered as that zone. The open happened while `DateLUT::getImplementation` held its global mutex, so a name pointing at a FIFO or a hung network mount would have blocked every time zone lookup server-wide. Make the check an allow-list: a name is accepted only if it is in the time zone database linked into the binary - which is exactly what `system.time_zones` lists, and what the documentation of the `DateTime` type and of `session_timezone` already tell users to use - or if it is one of the 114 `Fixed/UTC±HH:MM:SS` names for the offsets a time zone can really have. So the cache holds at most 712 entries. This closes the padded spellings and the `file:` prefix in one line, subsumes the `libc:` prefix, and makes the message the check reports true. The `cctz` fallback in `custom_factory` is dropped as well, so no name can reach the host's filesystem even if it gets past the predicate. Names that only the host's time zone database has are no longer accepted. ClickHouse ships its own tzdata precisely so that results do not depend on the host, such a name is absent from `system.time_zones`, and `timezone()` answering a name that no user can spell is itself wrong. The one place where the host chooses the name is the server's own local time zone, so `DateLUT` reports that case at startup, naming the zone and how to override it. This does not make the cache small - the 598 names of the time zone database plus the 114 fixed offsets still reach ~3.2 GB if all of them are used - it makes it bounded. Shrinking a `DateLUTImpl`, or evicting entries, is a separate matter (#107459). A misspelled time zone name is now reported as "Time zone X is not supported. Use a name from `system.time_zones`, ..." instead of "Cannot load time zone X", so `03926_arrow_fixed_offset_timezone` is updated. `05059_formatDateTime_extralong_timezone` checked the 32-byte limit that `formatDateTimeInJodaSyntax` puts on a time zone name, using `'Etc' || repeat('/', 26) || 'UTC'` to reach exactly 32 bytes. That spelling is one of the ones this rejects, and the longest real name, `America/Argentina/ComodRivadavia`, is exactly 32 bytes, so the test uses it instead: the name the per-row reservation has to fit is a real one, and nothing longer can be constructed. Closes: #120188 Related: #119634 Related: #118286 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [db0df38] Summary: ✅
AI ReviewSummaryThis PR tightens time zone acceptance to the embedded tz database plus canonical Final VerdictStatus: ✅ Approve LLVM Coverage ReportMeasured on commit db0df38.
Changed lines: Changed C/C++ lines covered: 53/60 (88.33%) · Uncovered code |
`getTimeZone`, the lookup of the time zone database linked into the binary, took a `const char *`, so it stopped at the first `\0`. Names reach it from length-prefixed carriers - a SQL literal, `readStringBinary` in binary type decoding - and `DateLUT::impls` keys on the whole byte string, so `UTC\0<anything>` was accepted, loaded the `UTC` blob, and took a cache entry of its own for every suffix: SELECT toDateTime(0, 'UTC\0x'); 1970-01-01 00:00:00 That is the allow-list of the previous commit defeated by one more unbounded family of spellings. Peak RSS of one `clickhouse-local` process, before this change: 100 queries using `UTC` cost 226 MB, and 100 using distinct `UTC\0<n>` spellings of it cost 680 MB. So give the generated lookup a `std::string_view` parameter, which makes both the predicate and the loader compare the whole name. The `Fixed/UTC±HH:MM:SS` branch was already matched by length, since it checks the size of the offset part. Found by the AI review of #120288 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Confirmed and fixed in b4c2e9f. The finding is right, and it is reachable from plain SQL too — a string literal is a length-prefixed carrier as much as Peak RSS of one Took the first of the two suggestions: the generated lookup now takes a Note this predates the PR — the same Regression tests in Re-verified after the change that all 598 names of |
|
CI on
Everything that exercises this change is green, including Re-ran the four failed jobs. |
|
Follow-up on the reds — both are now filed, and
Neither job ran a single test, and both fail the same way on |
`isSupportedTimeZoneName` checked only the total offset of a `Fixed/UTC±HH:MM:SS` name, but `cctz` normalizes the components, so `Fixed/UTC+00:75:00` and `Fixed/UTC+01:14:60` load the very same `+01:15` zone as `Fixed/UTC+01:15:00` does. One offset therefore had several names, and with them several permanent entries of the `DateLUT` cache - the aliasing this predicate exists to prevent, and the same defect as the dot segments and the embedded `\0`, inside the `Fixed/` branch. Reject out-of-range components before the total-offset check, so a fixed offset has exactly one spelling and the bound this change describes holds: the 598 names of the time zone database plus 114 fixed offsets. Negative coverage in `05218_time_zone_names_from_database` through `toDateTime`, `toDateTime64`, `CAST(... AS DateTime(...))` and `session_timezone`, next to the canonical spelling, which is still accepted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Merged The only red on the previous head was Zero comparison data is involved from this branch — @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120288&sha=835727aaf3262c20f8fc8706698d108c121e336d&name_0=PR&name_1=Build%20profile%20diff and provide a fix in a separate PR. If the fix is already in progress, link it here — note #120121, which would have turned exactly this class of read failure into a skipped comparison, was closed unmerged. Related: #120462 |
|
Investigated. It is not a query the endpoint refuses: every attempt timed out without ever getting an answer. What the log says. It is fleet wide and still going. In The fix in flight is yours, #121048. A One thing worth settling before #121048 merges. #121048 is |
…ases `determineDefaultTimeZone` returns the path of the host time zone file relative to the time zone database directory, and that path keeps the `posix/` or `right/` directory component when the host points its local zone at one of those alternate copies - `/etc/localtime -> /usr/share/zoneinfo/right/Europe/Berlin`, or `TZ=posix/Europe/Berlin`. Neither prefixed name is in the database linked into the binary, so with the allow-list this pull request introduces the server refused to start on such a host. Confirmed with a control: `posix/Europe/Berlin` and `right/Europe/Berlin` are both rejected by `isSupportedTimeZoneName`. Strip the prefix in the two relative-path fast paths, which are the only places that see the host-selected name verbatim - the content-scan fallback below them already skips both directories, so a name it returns is canonical already. `right/` zones count leap seconds, which ClickHouse does not model, so `right/Europe/Berlin` is `Europe/Berlin` here; that is also what the content scan resolves a copied `posix/` file to today. `05233_local_time_zone_posix_right_alias` builds a private time zone database with both directories and checks all five spellings resolve to `Europe/Berlin`, covering both the name that comes from `TZ` and the name that comes from the path of the file the local zone points to. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed On the reds from
|
|
Understood on both points.
#118708: stood down, no further pushes. I asked @ azat on the thread to confirm the close, #118708 (comment), since he has four review rounds in it and closed #120121 in its favour; I will close it on his word. If you would rather I not wait for that, say so and it is closed. One correction to my note above, from measuring again just now: the endpoint is flapping rather than down, so a re-run can pass between bursts. Since 01:20Z today, 257 errored |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units13 translation units recompiled, 29 s compile time in total, 13 of them have a recent master baseline. |
… docs The predicate now accepts exactly the names of the time zone database that is linked into the binary - what `system.time_zones` lists - plus the canonical `Fixed/UTC±HH:MM:SS` offsets, but three source-level doc strings still described the old contract: - `registerDataTypeDateTime.cpp` pointed at the IANA database as the list of supported zones, without saying that it is the shipped copy and not the host's, and without the fixed-offset spelling. - `ParserSetQuery.cpp` said `SET TIME ZONE` takes any valid IANA name. - `Settings.cpp` listed only `system.time_zones` names for `session_timezone` and omitted the fixed offsets, which the new error message itself mentions. All three now name the same set the code enforces, and say that a name only the operating system's database has is rejected. The generated pages under `docs/reference/` are regenerated from these strings, so they are left alone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed On the reds from Related: #121163 |
…one` server setting The startup exception pointed at the `timezone` server setting as the way to recover from a local zone ClickHouse does not know, but described it as taking "a name from `system.time_zones`" only. `DateLUT::setDefaultTimezone` goes through the same `DateLUTImpl::isSupportedTimeZoneName` allow-list as everything else in this change, so a canonical `Fixed/UTC±HH:MM:SS` offset is accepted there as well. Mention it, so the one recovery path the message names is described in full. The published `timezone` docs said "an IANA identifier", which both missed the fixed-offset form and implied that any IANA name works, including one that only the host's time zone database has. Restate them on the new contract. Only `docs/reference/settings/server-settings/_server_settings_outside_source.mdx` is edited: it is the source of truth that the server-settings generator reads, and the copy in `docs/reference/settings/server-settings/settings/other.mdx` sits inside the `AUTOGENERATED` markers. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
🕵 Both reds on
No test of this change failed; the full stateless/integration report on this head is clean. 0 unresolved review threads, AI Review verdict is |
…allowlist-120188 Pulls in #121272, which fixes the fleet-wide `Logical error: Incorrect table expression` (STID 3510-55f2) in `StorageView::replaceWithSubquery` that was the only non-infra red on this branch. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Merged The other red, |
`determineDefaultTimeZone` kept the raw `TZ` spelling whenever the name was relative, and the filesystem accepts many spellings of the same zone file that a zone name does not have: `Europe/./Amsterdam`, `Europe//Amsterdam`, a leading `./`, and any repetition of those. With the new allow-list such a name is no longer accepted - `isSupportedTimeZoneName` deliberately rejects the extra spellings, since each of them would otherwise be a separate `DateLUT` cache entry for one and the same zone - so `DateLUT::DateLUT` threw and the server refused to start on a host whose local time zone was configured that way. The raw spelling is preferred only because resolving symlinks can rename a zone (`/etc/localtime -> .../UTC -> UCT`), so keep it when the time zone database knows it, and otherwise use the name that resolving the path produced. This is the same regression class as the `posix/` and `right/` prefixes fixed earlier in this pull request, and the prefix stripping still applies on top of the resolved name. `05233_local_time_zone_posix_right_alias` gained the five non-canonical `TZ` spellings, with and without the POSIX `:` prefix, and two spellings that need both the prefix and the `./` component removed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed
New
The |
|
🕵 Merged The only red on Related: #121454
|
|
🕵 CI on The private sync PR https://github.com/ClickHouse/clickhouse-private/pull/75243 merges and builds; one shard failed, This is the known open crash #115501 ("Transaction log finalize failed during commit"; the issue records the trace as seen on |
… logs cluster outage When the read-only sub-service of the CI logs cluster stops answering, every `SELECT 1` readiness probe of `LogCluster.select` raises `requests.exceptions.ReadTimeout`. `is_ready` turned that into a bare False without a `probe_error`, so `select` raised `LogClusterNotReady`, which `build_profile_diff_job.main` does not catch, and the check went red on unrelated PRs (8 of them on 2026-11-06 between 00:00Z and 02:52Z, e.g. job 127646247697 of ClickHouse#129611). The same outage hitting a POST already ends `LogClusterUnavailable` (ClickHouse#121048), and so does a probe the server rejects with 241 (ClickHouse#128067). A probe that raises `ReadTimeout` now records `LogClusterUnavailable` in `probe_error`, and the tail added by ClickHouse#128067 reports the read green as "the endpoint never became ready: the readiness probe timed out: ...". The last probe decides, as there. A `ReadTimeout` (requests 2.33.0, the CI pin) is raised only after the name resolved and a server accepted the connection: a stalled TLS handshake or a stalled answer. Connection refused, an unresolvable name, no SYN-ACK and a certificate mismatch raise `ConnectionError` (`ConnectTimeout` and `SSLError` are subclasses), and the server itself rejects a rotated password with 516. All of those, a missing secret and a gateway answer still end `LogClusterNotReady`, as ruled on ClickHouse#120288. This is the `SELECT 1`-timeout leg left open on ClickHouse#121048. Validated with a throwaway harness against master (real sockets, mocked transport and `main()` end to end); only the probe-timeout cases change. No test is committed for the CI scripts (ClickHouse#119766). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #120188
Related: #119634
Related: #118286
isSupportedTimeZoneNamewas a deny-list of two prefixes,libc:(#119634) andFixed/(#118286), so acceptance of every other name was delegated to whatever
cctz's filesystemfallback could open. That set is not the time zone database.
cctzresolves a name as a path under the time zone database directory, and with afile:prefix as an arbitrary path, so one zone has unboundedly many names. On
master:None of those names is in
system.time_zones(count() = 0), the number of spellings of onezone is unbounded (
./repeats, extra/,file:+ any path), and every distinct name thatgets loaded permanently costs ~4.6 MiB in the
DateLUTcache, which never evicts anythingbecause callers keep bare references into it. So the cache that the two previous fixes were
bounding was still unbounded, reachable through
toDateTime(x, '<name>'), thesession_timezonesetting, binary type decoding, or the time zone of an Arrow or ORC timestampcolumn. Peak RSS of one
clickhouse-localprocess:Europe/Amsterdam./-padded spellings ofEurope/Amsterdam./-padded spellings ofEurope/Amsterdamfile:spellings ofUTCThe last row is the cost of the exceptions themselves: after the change, the 100 rejected
spellings cost 400 MB, which is that reference and not
DateLUTgrowth.file:was also a way to read a file outside the time zone database directory, which is exactlywhat the
CheckTimeZoneNameguard vendored intocontrib/cctzexists to prevent - it stripsthe prefix and uses the rest as the path, so the guard's check on the beginning of the name
never sees the leading
/. A TZif file copied anywhere on the filesystem loaded and answered asthat zone:
The open happened while
DateLUT::getImplementationheld its global mutex, so a name pointingat a FIFO or a hung network mount would have blocked every time zone lookup server-wide.
There is a third family, found by the AI review of this PR:
getTimeZone, the lookup of thebuilt-in database, took a
const char *and so stopped at the first\0. Names arrive fromlength-prefixed carriers - a SQL literal,
readStringBinaryin binary type decoding - whileDateLUT::implskeys on the whole byte string, soUTC\0<anything>loaded theUTCblob undera cache key of its own:
100 queries using
UTCcost 226 MB of peak RSS, 100 using distinctUTC\0<n>spellings cost680 MB. The generated lookup now takes a
std::string_view, so both the predicate and theloader compare the whole name; the same 100 spellings now cost 392 MB, against the 385 MB
reference above.
The change
Make the check an allow-list: a name is accepted only if it is in the time zone database linked
into the binary - which is exactly what
system.time_zoneslists, and what the documentation ofthe
DateTimetype and ofsession_timezonealready tell users to use - or if it is one of the114
Fixed/UTC±HH:MM:SSnames for the offsets a time zone can really have (#118286). So thecache holds at most 712 entries. This closes the padded spellings and the
file:prefix in oneline, subsumes the
libc:prefix, and makes the message the check reports true. Thecctzfallback in
custom_factoryis dropped as well, so no name can reach the host's filesystem evenif it gets past the predicate.
Names that only the host's time zone database has are no longer accepted. This is the
trade-off the issue names. ClickHouse ships its own tzdata (currently
2026c, 598 zones)precisely so that results do not depend on the host; such a name is absent from
system.time_zones, so no user can discover or portably use it; andtimezone()answering aname that
system.time_zonesdoes not list is itself wrong. The one place where the host choosesthe name is the server's own local time zone, so
DateLUTreports that case at startup, namingthe zone and how to override it, instead of leaving
DateLUTImplto report an unsupported namewith no hint that the host, and not a query, chose it.
This does not make the cache small - the 598 names of the time zone database plus the 114 fixed
offsets still reach ~3.2 GB if all of them are used - it makes it bounded. Shrinking a
DateLUTImpl, or evicting entries, is a separate matter (#107459).Verified that all 598 names of
system.time_zonesand all 114 fixed offsets are still accepted.Tests
New:
05218_time_zone_names_from_database, including the embedded-\0spellings throughtoDateTime,toDateTime64,CAST(... AS DateTime(...))andsession_timezone.03926_arrow_fixed_offset_timezone: a misspelled time zone name is now reported asTime zone X is not supported. Use a name from `system.time_zones`, ...instead ofCannot load time zone X.05059_formatDateTime_extralong_timezonechecked the 32-byte limit thatformatDateTimeInJodaSyntaxputs on a time zone name, using'Etc' || repeat('/', 26) || 'UTC'to reach exactly 32 bytes. That spelling is one of the ones this PR rejects, and the longest
real name,
America/Argentina/ComodRivadavia, is exactly 32 bytes, so the test now uses it: thename the per-row reservation has to fit is a real one, and nothing longer can be constructed.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix unbounded memory growth from time zone names that were not names of the time zone database:
dot segments or repeated separators inside a real name (
Europe/./Amsterdam,Europe//Amsterdam), thefile:prefix, which took the rest of the name as a path and read afile outside the time zone database directory, and a name carrying a zero byte, which was matched
against the database only up to that byte. None of these is listed in
system.time_zones, onezone had unboundedly many of them, and every distinct name permanently cost ~4.6 MiB that the
server never gave back. A time zone name now has to be one that
system.time_zoneslists, or afixed UTC offset spelled
Fixed/UTC±HH:MM:SS; a name that only the host's time zone database hasis no longer accepted.
Workflow [PR]
Sync PR [sync-upstream/pr/120288]
Version info
26.10.1.434-master(included in26.10and later)