Skip to content

Pin the timezone in the default TimeSeries partition key - #120960

Merged
alexey-milovidov merged 19 commits into
ClickHouse:masterfrom
valerypetrov:fix/timeseries-partition-key-timezone
Oct 18, 2026
Merged

alexey-milovidov merged 19 commits into
ClickHouse:masterfrom
valerypetrov:fix/timeseries-partition-key-timezone

Conversation

@valerypetrov

@valerypetrov valerypetrov commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

The default partition key of the inner recent samples table of a TimeSeries table is now anchored to UTC. Previously it depended on the server timezone, so changing that timezone made range queries silently skip whole parts.

Documentation entry for user-facing changes

The engine reference states the default partition key; it is regenerated from the changed source strings.


Closes the defect reported in #120944.

When the user declares no partition key, the inner recent samples table is generated with:

PARTITION BY toStartOfInterval(toDateTime(timestamp), toIntervalHour(5))

toStartOfInterval counts hours from local midnight, not from the epoch (DateLUTImpl.h, toStartOfHourInterval: "We will round the hour number since the midnight. It may split the day into non-equal intervals."), and nothing in that expression pins a timezone. Every partition value already written therefore means a different instant once the server timezone changes.

The failure is silent. Pruning maps the query bounds through the expression as it reads today, the values written under the earlier timezone are no longer on that grid, and parts that match the predicate are eliminated:

SELECT countIf(timestamp >= toDateTime64(1789683000,3) AND timestamp <= toDateTime64(1789684000,3)) FROM t;
-- 5079
SELECT count() FROM t WHERE timestamp >= toDateTime64(1789683000,3) AND timestamp <= toDateTime64(1789684000,3);
-- 1

The discarded part is not damaged: its partition value is what the declared expression yields for its rows, and its min-max index decodes to exactly its true range. Reached through PromQL, this returns an empty result for data that is present. The rows are not lost — they come back when the server timezone is put back, and the row written under the other timezone becomes the hidden one instead.

@groeneai diagnosed the timezone as the ingredient in #120944, including the minimal reproduction and the confirmation that pinning the timezone removes the failure mode. This is that change.

What it changes

'UTC' is pinned in the generated default from table version 8, which this PR adds as the latest TimeSeries version. A table of an earlier version, including one created with an explicit older version, keeps the old default. The expression lives in two places — the one that builds it and the one that recognises it, so a redundant declared key is still elided from SHOW CREATE — and both move together, otherwise normalization stops recognising its own default. The engine and setting documentation strings move with it; the .mdx reference pages are inside AUTOGENERATED markers and are regenerated from those strings.

recent_samples_partition_by, when set explicitly, is untouched: a user who chose an expression keeps exactly what they chose.

The TTL expression is deliberately left alone. toDateTime(timestamp) + toIntervalSecond(N) compared against now() is epoch arithmetic and carries no timezone dependency.

Scope, stated plainly

Only tables created from here on benefit. An existing inner table already carries its own materialized partition key, which this change does not and cannot rewrite — MergeTree has no MODIFY PARTITION BY. A table written under one timezone still needs that timezone to read its older parts. Whether existing tables get a migration path is a separate question for the engine owner, and I have not attempted one here.

Two guards. The generated DDL is asserted in 05019_time_series_recent_samples_table.reference, 05026_time_series_recent_samples_default.reference and gtest_normalize_time_series_definition, all of which fail the moment the pin is removed. And test_timeseries_partition_key_timezone is behavioural: insert now()-relative samples, restart the server with a different <timezone> in its config, then re-run the range query. That recipe is @groeneai's, from his review comment — it sidesteps the 4-day TTL, which is what I had wrongly concluded made a behavioural test impossible here.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/120960]

Version info

  • Merged into: 26.11.1.157-master (included in 26.11 and later)

The inner recent samples table is partitioned by
`toStartOfInterval(toDateTime(timestamp), toIntervalHour(5))` when the user
declares no partition key of their own. `toStartOfInterval` counts hours from
local midnight rather than from the epoch, and nothing in that expression pins
a timezone, so every partition value already on disk means a different instant
once the server timezone changes.

The consequence is silent. Partition pruning maps the query bounds through the
expression as it reads today, the values stored by the earlier timezone are no
longer on that grid, and whole parts are eliminated from a range query that they
match: a table returning 5079 rows for a predicate returns 1, with no error, and
PromQL over it answers with an empty result for data that is present. The rows
are not lost, and come back if the server timezone is put back.

Pinning UTC in the generated default removes the dependency: someone who never
chose a partition key should not inherit a silent one on the server's timezone.
The expression is written in two places, the one that generates it and the one
that recognises it to keep it out of `SHOW CREATE`, and both move together.

Only tables created from here on are affected. An existing inner table already
carries its own partition key, which this does not and cannot rewrite, so a
table written under one timezone still needs that timezone to read its older
parts. Whether those get a migration path is a separate question.

Reported in ClickHouse#120944, where the timezone was diagnosed as the ingredient.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QtEKPyQDMCBZfJkiJcs789
@clickhouse-gh clickhouse-gh Bot added the comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... label Sep 19, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Sep 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6a1a49c]

Summary: ✅


AI Review

Summary

The PR pins the generated TimeSeries recent-samples partition key to UTC from table version 9, preserves earlier versions, and adjusts custom-engine copying. Request changes: the nullable-key fix still misses a supported legacy-source case.

Findings

⚠️ Majors

  • normalizeTimeSeriesDefinitionImpl.cpp:1016: Copying a custom tags engine must preserve settings required by retained columns. Recognizing the old sorting key containing min_time and max_time does not prove that those are its only nullable columns. This valid source still cannot be copied:

    SET enable_time_series_table = 1;
    CREATE TABLE src ENGINE = TimeSeries
    SETTINGS version = 7, aggregate_min_time_and_max_time = 0
    TAGS INNER COLUMNS (metric_name Nullable(String), v UInt64)
    TAGS ENGINE = ReplacingMergeTree(v);
    CREATE TABLE copy AS src;

    The source gets allow_nullable_key = 1 and the full legacy sorting key. Copying removes that setting along with the key, retains nullable metric_name, and generates the new (metric_name, id) key without restoring the setting. The copy throws ILLEGAL_COLUMN (code 44). Reproduced with the PR's 80b5fcbc ARM build; its normalization source blob matches the reviewed head. Preserve allow_nullable_key when the resulting sorting or partition key still needs it. This is a remaining case of the existing nullable-key finding; that bot-resolved thread was reopened without a duplicate comment.

Tests
  • ⚠️ Add a focused stateless copy test combining the version-7 full sorting key with nullable metric_name and a custom engine. The added tests cover these features separately and miss their interaction.
Final Verdict

Status: ⚠️ Request changes. Preserve the required nullable-key setting for the legacy-source case and add its regression test.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

Thanks for picking this up. I had the same change in progress and yours covers the same two sites, so I am not opening a duplicate. Two things I hit while implementing it, both of which the keyValuePairs tags index went through five days ago in 009e36d15fef5:

1. CREATE TABLE b AS a where a was created before this change. removeGeneratedInnerEngine is documented to strip the parts that "look like generated by normalizeInnerEngine of the current or of an older version of the server, so that they are generated again", and the strip is a string comparison against expected_partition_by. This PR moves that string to the pinned form, while an existing table's own definition carries the unpinned one: it is the RECENT SAMPLES INNER ENGINE line in the SHOW CREATE TABLE example this PR edits. So for every table created before this change the comparison now fails, the declaration is kept instead of regenerated, and the copy is created with PARTITION BY toStartOfInterval(toDateTime(timestamp), toIntervalHour(5)) written out explicitly, which no later change can regenerate away. Deriving the expected text from the source table's version avoids that: recognition runs with the source's version (unpinned for 5 and below), generation with the copy's own LATEST, so the copy comes out pinned.

2. The version gate. TimeSeriesVersion.h: "Bump it each time the schema of the target tables or the semantics of the stored data changes; every version in [MIN_SUPPORTED, LATEST] must stay supported, so either make the schema generation version-aware or bump MIN_SUPPORTED too." As it stands, CREATE TABLE ... SETTINGS version = 5 on a patched server produces a table an unpatched server would never produce for version 5. 009e36d15fef5 bumped LATEST for the same class of change, and the version-aware generation that rule asks for is also what makes point 1 fall out.

3. A behavioural test is possible. The failure needs no absolute timestamp, so the 4-day TTL is not in the way: insert now()-relative samples, restart the server with a different <timezone> in its config, then run the range query. I have that as an integration test plus a stateless one for the generated DDL, both verified to fail without the fix (the integration one reports "a range query returned 0 of the 40 samples in that range after the server timezone changed"). Happy to hand them over, or to open them separately once this lands if you would rather keep the PR minimal.

@clickhouse-gh

clickhouse-gh Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6a1a49ca2 with master 0a3052562 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

81 translation units recompiled, 212 s compile time in total, 81 of them have a recent master baseline.

Job report

…t change

The previous commit changed the generated default for every table, including one
created with an explicit `version`. `TimeSeriesVersion.h` requires the opposite:
a change to the schema of the target tables either bumps the version or stays
version-aware, so that `SETTINGS version = N` keeps reproducing the definition
that version described and two nodes of different releases normalize the same
DDL the same way.

So the pinned timezone is version 6, and version 5 and below keep generating the
expression they always generated. The spelling a version generates is also the
spelling it recognises as generated, which is what lets `CREATE TABLE copy AS
src` strip an older table's own default and regenerate it rather than carrying a
clause that then looks explicit.

An existing table therefore keeps the partition grid it was written on, which is
the only thing that can be said for one: its parts are already placed, and no
`ALTER` can move a partition key. Only a table created at version 6 gets a grid
that survives a server timezone change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QtEKPyQDMCBZfJkiJcs789
Comment thread src/Storages/StorageTimeSeries.cpp Resolved
valerypetrov and others added 2 commits September 19, 2026 10:47
…plit with tests

Bumping `LATEST` left the generated engine reference describing version 5: the
example `SHOW CREATE` output, the default of the `version` setting, the prose
naming the latest version, and a version history that stopped one row short,
all on the same page that now shows the version 6 partition key. That documents
a definition nobody can get.

The tests only covered the latest version too, so neither half of the split was
actually pinned. `SETTINGS version = 5` keeping the expression it always
generated is now asserted, and so is the copy case: a version 5 source table has
its generated key recognised by its own spelling, stripped, and regenerated with
the timezone named, because a copy is a new table at the latest version.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QtEKPyQDMCBZfJkiJcs789
Three stateless tests failed, all on my own expectations rather than on the code.

`engine_full` comes back with the quotes of a string literal escaped, so the
generated partition key reads `toDateTime(timestamp, \'UTC\')`. I had rewritten
those two references by substituting the unescaped spelling instead of taking
what the server prints, which is the whole reason the server was run in the
first place.

`04612_timeseries_version_setting` extracts the version as a bare number, so it
asserted `5` where nothing spelled `version = 5`, which is why searching for that
string did not find it. Its four per-version checks create versions 0 to 3
explicitly and are unaffected.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QtEKPyQDMCBZfJkiJcs789
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 20, 2026
… copy

When copying a TimeSeries table with an inner engine declared with arguments
(such as `RECENT SAMPLES ENGINE = ReplicatedMergeTree(...)`),
`removeGeneratedInnerEngine` previously returned early before checking
`partition_by`, leaving the source table's legacy partition key in place
and preventing `normalizeInnerEngine` from regenerating the pinned UTC key
for the new version 6 table.

Strip generated partition keys, TTL, sorting keys, and settings even when
the engine has arguments or is a custom kind, while preserving the custom
engine itself so that copies remain replicated or custom.
Dropping the early returns for engines with arguments left the sorting-key
stripping running for them. A source like

  SAMPLES ENGINE = ReplacingMergeTree(timestamp) PRIMARY KEY id ORDER BY (id, timestamp)

matches the generated key, so `CREATE TABLE ... AS` cleared its ORDER BY. Nothing
put one back: the regeneration is guarded on there being no primary key, and the
primary key survives. The copy then reaches MergeTree with neither and is
rejected with "ORDER BY cannot be empty".

The three branches that drop a sorting key on its own now refuse to while a
primary key is present. The tags branch is untouched, since it already drops the
pair together and only when both were generated.

Coverage goes next to the existing copy test: a custom samples engine carrying
its own primary key is copied, and the copy keeps both clauses. The expected
output was taken from a build without this branch, where the early return kept
the same behaviour.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QtEKPyQDMCBZfJkiJcs789
@valerypetrov

Copy link
Copy Markdown
Contributor Author

@groeneai , do your magic with the CI once again, please.

@groeneai

Copy link
Copy Markdown
Collaborator

Three reds on 5614a3aa, none of them caused by your change. Everything else that has finished is green; about 50 jobs are still running.

BuzzHouse (amd_debug) fails with LOGICAL_ERROR: RWLockImpl::getLock(): RWLock is already locked in exclusive mode (STID 2043-36a4), the same signature I attributed on #120942. DROP / TRUNCATE of an Alias table takes the table's exclusive lock twice under one query id: InterpreterDropQuery::executeToTableImpl already holds it, then StorageAlias::truncate (src/Storages/StorageAlias.cpp:310) calls IStorage::lockExclusively again. It is a regression from my merged #119105, reported in #121129, and my fix is open in #121134. It is not specific to your branch: over the last two days CIDB has the same signature on master itself (BuzzHouse (amd_tsan), 2026-09-21 13:59 UTC) and on 12 other pull requests. BuzzHouse generates random statement sequences, so a given run only reds when the sequence reaches that path.

Integration tests (amd_asan_ubsan, db disk, 1/8) fails in test_max_bytes_ratio_before_external_distinct[server] at test.py:134 with Code: 241. (total) memory limit exceeded: would use 2.65 GiB (attempt to allocate chunk of 64.50 MiB), current RSS: 3.96 GiB, maximum: 4.00 GiB. The 4 GiB ceiling is the server total on that shard, not the per-query limit the test sets, so the test's own assertion never runs. The same test in the same job hit the same signature on master 5 times in the last two days (latest b390c780, 22:07 UTC) and on 31 other pull requests. My #121096 is already in your branch (merged yesterday 17:42 UTC, 86 commits behind your head), but it trimmed that test for the 600 s client-timeout flavour, not for this memory-cap one, so it does not cover this failure. It clears on a re-run.

CH Inc sync is the private ClickHouse Inc mirror. I have no visibility into it and it is not actionable from here.

One thing in the report that looks alarming but is not: Bugfix validation lists 05059_time_series_create_as_keeps_settings and test_timeseries_partition_key_timezone as failing tests. Those jobs run your new tests against a master build without your fix and then invert the result, so a failing test there is the intended outcome. All four Bugfix validation jobs are green.

If the remaining jobs red on something else, ping me and I will attribute it.

# Conflicts:
#	src/Storages/StorageTimeSeries.cpp
#	src/Storages/TimeSeries/TimeSeriesVersion.h
#	src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp
pull Bot pushed a commit to stnxo2023/ClickHouse that referenced this pull request Sep 23, 2026
…cenario

`Storage memory check` fails unrelated PRs with a byte-constant
`change=+1,056`. Since ClickHouse#120487 removed the one-time initialization offset,
9 heads had `+1,056` as their only failing scenario, on
`03_add_secondary_indexes.sql` and `04_add_projection.sql`.

A pooled thread that runs a mutation step attaches to the task's
`ThreadGroup` through `ThreadGroupSwitcher`, and that attach constructs
thread-local performance-counter state: `TasksStatsCounters`, a
`ProcfsMetricsProvider`, and two `__cxa_thread_atexit_impl` registrations
which by construction live until the thread exits. `GlobalThreadPool` keeps
its threads, so those bytes stay live once a thread has participated, and
the quantity the checkpoint diff measures is how many distinct pool threads
have ever served the scenario. Which window a thread's first participation
lands in is a scheduling draw.

It is one cluster of 7 stacks costing exactly 528 bytes per participating
thread: +384 `TasksStatsCounters::create`, -64
`ThreadGroup::SharedData::SharedData`, +64 `detachFromGroup`, +48
`make_shared<ProcfsMetricsProvider>`, +32 and +32 for the two
`__cxa_thread_atexit_impl` registrations, +32 for the query-id string copy
in `applyQuerySettings`. The gate is `absolute_change > 1024 AND
percent_change > 1.0`, so one unit passes and two clear it by 32 bytes: the
threshold sits inside the noise quantum. PR ClickHouse#120702 at `b48703670359` has
rows for `04_add_projection.sql` at both 528 and 1,056, the same commit
measured twice with different answers, so no threshold value could measure
this quantity.

Raising the threshold is the move that already failed: `150d1f2d0290b`
raised this lane from the parser lane's 100 to 1,024 for this exact
mechanism, and two units cleared it three days later. Waiting for
background tasks to quiesce cannot work either, because this state is
registered with `__cxa_thread_atexit_impl` and is not a teardown tail.
Pinning the pools to one thread would be C++-side, and the master arm
binary is downloaded from the merge base, so such a fix is asymmetric until
it reaches master.

Instead add the three thread attach/detach frames to the analyzer's
existing `EXCLUDED_STACK_FRAME_PREFIXES`, which `compute_diff` already
consults before a stack reaches the gated total. Both arms of a run are
analysed by the same script from the same checkout, so the change applies
symmetrically from the first run, and keying on the allocation site covers
every pool at once rather than enumerating pools or settings.

On the production reports for ClickHouse#118967, ClickHouse#120960, ClickHouse#121251 and ClickHouse#120702,
removing this cluster takes every failing scenario's change to exactly 0,
with the largest residual anywhere 64 bytes against the 1,024-byte
threshold. Locally, 20 repeated two-pass runs of one binary reproduce the
528-byte unit with the same 7-row composition and a multiplicity that
varies run to run; an injected 64 KiB-per-table allocation is still
reported at full size; and reverting only these three prefixes restores the
pre-fix numbers byte-for-byte.

Two consequences are deliberate. The cluster rows also leave the HTML
report, exactly as `dumpProfile` overhead already does, because a row the
check must not gate on should not be presented as a finding. And
thread-accounting regressions are no longer measured here, which the
same-commit pair above shows was never possible anyway.

`STORAGE_CHANGE_THRESHOLD_BYTES` is left at 1,024. Removing this noise is
what would make lowering it toward the parser lane's 100 possible, but that
is a calibration decision with its own data.

Related: ClickHouse#120487
Related: ClickHouse#119480

Co-Authored-By: Claude Opus 5 <[email protected]>
@valerypetrov

Copy link
Copy Markdown
Contributor Author

Should be ready for review.

Master changed the link on the version 6 row of the TimeSeries version
table, next to the version 7 row this branch adds. Keep master's row 6
and the branch's row 7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
valerypetrov and others added 2 commits September 29, 2026 09:40
`master` took version 7 of `TimeSeries` for the deduplication caches (ClickHouse#121915),
so the pinned timezone of the default recent samples partition key moves to
version 8: `MIN_WITH_UTC_PARTITION_KEY = 8`, `LATEST = 8`, and the version
history in `TimeSeriesVersion.h` and in the engine documentation gets both rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The latest version is 8 now, and version 7 is the last one generating the
partition key without a timezone, so the unit test checks the boundary on it.

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

Copy link
Copy Markdown
Contributor Author

Should be ready for review.

@alexey-milovidov alexey-milovidov self-assigned this Oct 15, 2026
Upstream used `TimeSeries` version 8 for moving `min_time` and `max_time` into the time ranges target table (`MIN_WITH_TIME_RANGES_TARGET`), so the pinned `UTC` partition key of the recent samples table becomes version 9:

- `TimeSeriesVersion.h` (moved to `src/Parsers/Prometheus/`): `MIN_WITH_UTC_PARTITION_KEY = 9`, `LATEST = 9`, the version history has both entries.
- `removeGeneratedInnerEngine`: the `TimeRanges` kind and the tags engine kind from `getGeneratedTagsEngineKind` use the `engine_is_generated` flag, so an engine with arguments is kept as it is.
- The docs in `StorageTimeSeries.cpp`, the `gtest_normalize_time_series_definition.cpp` expectations and the reference of `04612_timeseries_version_setting` say version 9; the explicit version 8 keeps the partition key without a timezone.

Review: ClickHouse#120960 (review)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@valerypetrov

Copy link
Copy Markdown
Contributor Author

@groeneai , please check why the CI is failing, and prepare fix if applicable.

@groeneai

Copy link
Copy Markdown
Collaborator

One red on b3dfaec5, and it is not caused by your change. Every other job that ran is green, and Mergeable Check is red only because of this one.

Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) fails in 05345_text_index_prewhere_read_step_order with the single line read_order_index_first 0 -> 1. All result rows match, and the runner's 99 reruns with the same random settings passed. The test came in with #124880 (merged yesterday) and compares RowsReadByPrewhereReaders with SelectedRows on the initiator's query_log row only. When a remote replica reads some of the marks, it counts those rows on its own row, so the checked ratio drops below the threshold. The same diff has hit this job on master 10 times in the last two days (latest 7055af30, 17:01 UTC) and 51 other pull requests. My fix is #125892: it changes only the test and runs the four measured reads with enable_parallel_replicas = 0. Nothing needs to change in your PR, and the job usually passes on a re-run.

CH Inc sync is the private ClickHouse Inc mirror. I have no visibility into it.

Bugfix validation lists your two new tests as failing again. As before, that is the intended inverted result, and all four of those jobs are green.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks, @groeneai. Since 05345_text_index_prewhere_read_step_order is flaky under parallel replicas and the test-only fix is in #125892 (still open), the PR needs no change for it. I merged the latest master (no conflicts, no overlap with the changed files) to restart CI.

valerypetrov and others added 2 commits October 15, 2026 20:08
`CREATE TABLE ... AS` strips the parts of the source's inner engines that look
generated, so they are generated again for the new table. Since the stripping
also runs for engines with arguments and for engines of another kind, it removed
`allow_nullable_key = 1` together with tags keys that look generated, for example
`ReplacingMergeTree(v) PRIMARY KEY metric_name ORDER BY (metric_name, id)` over
a `Nullable(String)` metric name. The nullable column is kept and the keys are
generated again, but the setting was not, so the copy failed with ILLEGAL_COLUMN.

The generator adds `allow_nullable_key` only for the nullable `min_time` and
`max_time` in the sorting key of older versions, so the setting is now removed
only together with that key. A declared one is kept for the user's own nullable
key column. This also fixes the same copy for a generated tags engine without
arguments, which failed before this PR as well.

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

Copy link
Copy Markdown
Member

🕵 The only red on 80b5fcbc was Performance Comparison (arm_release, master_head, 4/6), which hit the job-level timeout (Job timed out ... timeout [7200], exit code [-15]) while still running perf.py over ordinary perf tests (parquet_dictionary_filter.xml and earlier), on a runner labeled disk-almost-full. None of those tests touch TimeSeries, so it is not caused by this change. I merged the latest master (no conflicts, no master changes in the touched TimeSeries files; the changed translation units compile) to get a fresh CI run.

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/PRs/120960/80b5fcbc7daca99387d33940e3158e947ad6c062/pr/performance_comparison_arm_release_master_head_4_6/job.log and provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

This PR didn't cause it. The 4/6 shard lost an hour in the CI Logs export setup before perf.py started:

  • The SELECT 1 connection check in ci/jobs/scripts/functional_tests/setup_log_cluster.sh blocked from 04:56:59 to 05:57:44 UTC and ended in ATTEMPT_TO_READ_AFTER_EOF. The CI Logs cluster was overloaded at the time: the next check got TOO_MANY_SIMULTANEOUS_QUERIES (1030 of 1000).
  • perf.py started only at 06:10:57, and the 7200 s job timeout killed it at 06:50:52. The other five arm shards of the same run finished in 67-85 minutes.
  • disk-almost-full is incidental: it is an informational label (peak disk 85-92%) on all six arm shards, including the five that passed.

The fix is #126217, merged on 2026-10-16 at 19:58 UTC, after this run. It caps every query that script sends to the CI Logs cluster at 90 s of wall-clock time, so an overloaded cluster now costs a job minutes instead of an hour. Your master merge (6a1a49ca) includes it. The cluster itself recovered the same morning: CIDB has 160 error results of Performance Comparison (arm_release, master_head, *) between 00:00 and 12:00 UTC on 2026-10-16 and none since. No other PR is needed for this.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks, @groeneai. Confirmed: the current head 6a1a49ca already contains the fix from #126217, so no change is needed in this PR for the Performance Comparison (arm_release, master_head, 4/6) timeout. The fresh CI run is in progress with no failures so far, and there are no open review threads.

…lumn

The generated `allow_nullable_key = 1` of a pre-v8 tags engine was removed on
`CREATE TABLE ... AS` together with its `min_time, max_time` sorting key. But the
same setting also lets a user's nullable column, like a `Nullable(String)`
`metric_name`, stay in the regenerated key, so the copy failed with ILLEGAL_COLUMN.
Now the setting is removed only if no copied column of the inner table is nullable.

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

clickhouse-gh Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

PromQL Compliance Report

Baseline: S3 master d6c2532ef

Suite Baseline Current Delta
Prometheus compliance 100.00% 100.00% +0.00%
Extended support (upstream engine tests) 92.90% 93.17% +0.27%
Suite Passed Failed Unsupported
Prometheus compliance 539 -> 539 (+0) 0 -> 0 (+0) 0 -> 0 (+0)
Extended support (upstream engine tests) 680 -> 682 (+2) 18 -> 16 (-2) 34 -> 34 (+0)

Extended support (upstream engine tests): native-histogram exclusions: 149; excluded assertions: 248; upstream 3da2514eff5c.

Note: Prometheus compliance score is unchanged vs baseline.

Uploaded compliance JSON for this PR commit

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 18, 2026
Merged via the queue into ClickHouse:master with commit 0710fd7 Oct 18, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 18, 2026
valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Oct 23, 2026
Master's ClickHouse#120960 changed removeGeneratedInnerEngine: each target now sets engine_is_generated, and a sorting key is dropped only while no primary key is declared. The histograms case kept the old early-return form, so after the merge its generated engine was never stripped and a declared PRIMARY KEY lost its ORDER BY on CREATE TABLE ... AS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... external Author is not a member of the ClickHouse organization pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants