Repository navigation
Capture the tags collector when creating timeSeriesStoreTags and timeSeriesTagsToGroup - #126492
Conversation
…SeriesTagsToGroup ClickHouse#104948 changed both functions to hold their creation context weakly and to look up the query's tags collector in executeImpl. The creation context is the scope context of the analyzer query node, and it does not always live as long as the pipeline. With parallel replicas and a local plan, createLocalPlanForParallelReplicas clones the query tree and gives every query node a fresh context copy, while the cloned function nodes share the original function objects. When the table of the parallel-replicas node is empty, the local plan is returned alone and the original contexts are released before the pipeline runs. A PromQL query over a TimeSeries table whose data table is empty then throws LOGICAL_ERROR `Context has expired` from timeSeriesStoreTags (seen in the Stress test (amd_msan) job, STID 1805-578d). Capture the collector in the constructor again, as before ClickHouse#104948 and as the other timeSeries tag functions do. The collector is created once per query context, so the captured object is the one the deferred lookup returned. Without a query context the function can still be created to read its signature (what ClickHouse#104948 wanted for system.functions); executing such an instance throws THERE_IS_NO_QUERY. Both files no longer use WithContext, so they are removed from the exception list of the style check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge the two-line constructor comments in timeSeriesStoreTags and timeSeriesTagsToGroup into one invariant line each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 rounds: 2, 3 and 0 findings) plus my own review.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261017-135900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261017-122100 |
|
cc @vitlibar @nikitamikhaylov, could you review this? Since #104948 |
|
Workflow [PR], commit [bc48c1b] Summary: ✅
AI ReviewSummaryThe PR makes Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; current-head test execution remains pending in CI. |
CI finish ledger - bb36b12Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The only other Session id: cron:our-pr-ci-monitor:20261018-073006 |
|
Fixing PR for the Performance Comparison (arm_release) |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 10 s compile time in total, 8 of them have a recent master baseline. |
…pped ClickHouse#126742 made TimeSeries version 10 (inner targets only) the default, so `CREATE TABLE ts ENGINE = TimeSeries DATA ts_data ...` now fails with INCORRECT_QUERY and the test fails before reaching the query it guards. The test needs time series whose tags and time ranges exist while the samples table has no parts. It used to get that by truncating an external data table. Inner tables have generated names, so now the tags are inserted with empty sample arrays and the time ranges are written through `timeSeriesTimeRanges`; the samples for the "with data" part are added through `timeSeriesSamples`. Inserting tags with empty samples alone is not enough: without time ranges no series matches and the query never reaches the parallel replicas local plan. Measured on a debug build: the snapshot master binary (31d10e5, no fix) dies on the test at timeSeriesStoreTags.cpp:117 'Context has expired'; the PR head passes it 50/50 with random settings, 10/10 with serialize_query_plan = 1 and 10/10 with a Replicated database. The reference is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With parallel replicas the `SELECT ... FROM timeSeriesTags(ts)` of the two fixture inserts is also sent to the remote replicas, which look up the bare `ts` in their default database and fail with UNKNOWN_TABLE. The test passed only when the local replica finished first: it failed 3/150 in the PR flaky checks (query 23, the samples insert), 1/50 locally in flaky-check mode, and 2/5 with parallel replicas enabled for the whole run (the ParallelReplicas job), there at the time ranges insert. Pin both fixture inserts to `enable_parallel_replicas = 0`. The empty-data queries keep running through parallel replicas, and the unfixed server still dies on the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse#117344 switched the samples inner table to the bucketed schema of version 11 (id, samples, bucket, min_time, max_time), so the fixture's `INSERT INTO FUNCTION timeSeriesSamples(ts) SELECT id, timestamp, value ...` fails on current master with NUMBER_OF_COLUMNS_DOESNT_MATCH (source: 3 and result: 5). Insert the samples through the TimeSeries table instead, which works with every samples layout. The reference is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PromQL Compliance ReportBaseline: S3 master
Extended support (upstream engine tests): native-histogram exclusions: 149; excluded assertions: 248; upstream Note: Prometheus compliance score is unchanged vs baseline. |
Related: #104948
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not required.
Description
Stress test (amd_msan)aborted withLogical error: 'Context has expired'inFunctionTimeSeriesStoreTags::executeImplon a PromQL query from05271_promql_label_matcher_pushdown(report, STID 1805-578d). It is a master-only regression from #104948, which madetimeSeriesStoreTagsandtimeSeriesTagsToGrouphold their creation context weakly and look up the tags collector inexecuteImpl.The creation context is the scope context of the analyzer query node. With parallel replicas and a local plan,
createLocalPlanForParallelReplicasclones the query tree with fresh context copies, but the cloned function nodes share the original function objects. If the table of the parallel-replicas node is empty (here the samples table, after an injected memory error failed the test'sINSERT), the local plan is returned alone, the original contexts are released, and the function finds its context gone when the pipeline runs.The change captures the collector in the constructor again, as before #104948 and as the other
timeSeries*tag functions do. A plain-SQL query (anINsubquery with aJOIN, over an empty table) reaches both functions the same way, so both are changed. Without a query context the function can still be created to read its signature; executing such an instance throwsTHERE_IS_NO_QUERY. Both files are removed from theWithContextexception list of the style check.The new test (a TimeSeries table with tags and time ranges but an empty samples table, parallel replicas with a local plan) makes the debug server abort on master and passes with the change, 50/50 with randomized settings and in the DBReplicated, parallel-replicas and distributed-plan flavours.
Workflow [PR]
Sync PR [sync-upstream/pr/126492]
Version info
26.11.1.1611-master(included in26.11and later)