Skip to content

PromQL: run the generated SQL with the analyzer on the HTTP API - #114261

Merged
nikitamikhaylov merged 5 commits into
ClickHouse:masterfrom
groeneai:promql-http-force-analyzer
Aug 14, 2026
Merged

nikitamikhaylov merged 5 commits into
ClickHouse:masterfrom
groeneai:promql-http-force-analyzer

Conversation

@groeneai

@groeneai groeneai commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

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

The Prometheus HTTP API endpoints /api/v1/query and /api/v1/query_range now evaluate a PromQL subquery shared by several plan steps once, as the prometheusQuery and prometheusQueryRange table functions already did. Previously a request made with enable_analyzer = 0, or by a user whose profile sets it, rescanned the shared subquery once per referencing step.

Description

Related: #113772, which marks a PromQL subquery referenced by more than one plan step AS MATERIALIZED so it is evaluated once.

AS MATERIALIZED is honored by the analyzer only, and the two PromQL entry points disagreed about the analyzer. StoragePrometheusQuery::readImpl builds InterpreterSelectQueryAnalyzer directly, so the table functions always run the analyzer. PrometheusHTTPProtocolAPI::executePromQLQuery hands the generated SQL to executeQuery(), which honors the caller's enable_analyzer. With the analyzer off, the endpoints rescanned the shared subquery and the enable_materialized_cte default that #113772 added there had nothing to act on.

Reachable two ways, both measured: as a URL parameter, since isSettingLikeParameter turns any non-reserved query parameter into a setting, and through the user profile, which is how the old-analyzer CI configuration reaches it.

The fix forces allow_experimental_analyzer on the request context immediately before the single executeQuery call, so the HTTP path matches the table-function path. The generated SQL is machine-built for the analyzer, and the caller's enable_analyzer should not change the plan of SQL they did not write. No setting default changes and results are unchanged.

Measured with read_rows from system.query_log, analyzer off via the profile: last_over_time(a) or last_over_time(b) read 880 rows before and 624 after, while sum(last_over_time(a)), which shares nothing, read 288 either way.

Results are identical in both modes, so a results-based test would pass either way. test_generated_sql_always_runs_with_analyzer in test_query_api.py therefore asserts the two settings the generated query ran with, over both endpoints, with enable_analyzer=0 on the request. The materialization itself is covered by 04816_promql_shared_subqueries_materialized.

Validation

The new test passes with the fix and fails without it on the assertion under test, reporting '1\t1' != '0\t1': the first column is what the fix sets, the second shows the request reached the handler. 10 of 10 repeats pass with the fix, and the whole test_query_api.py file is green under the default, old-analyzer and distributed-plan integration flavours; on the unpatched binary the other 10 tests in the file still pass, so only the new assertion moves.

The system.query_log read waits with assert_eq_with_retry(retry_count=30, sleep_time=1): the response is flushed to the client before the QueryFinish row is queued, so a single flush can precede the row and leave it waiting for the background interval. Measured on this instance the row appears 0.23s after the flush in 12 of 12 requests, and the longer retry does not mask the defect, since the unpatched arm still fails on the assertion.

An earlier revision of this PR carried a larger standalone test with a per-shape read_rows bound. It was replaced at review request.

…points

The PromQL-to-SQL converter marks a subquery referenced by more than one plan
step AS MATERIALIZED so it is evaluated once, and that mark is honored by the
analyzer only. The two PromQL entry points disagreed about the analyzer:
StoragePrometheusQuery::readImpl builds InterpreterSelectQueryAnalyzer directly,
so the table functions always run the analyzer, while
PrometheusHTTPProtocolAPI::executePromQLQuery passes the generated SQL to
executeQuery(), which honors the caller's enable_analyzer. With the analyzer off
/api/v1/query and /api/v1/query_range rescanned the shared subquery once per
referencing step, and the enable_materialized_cte default set next to that call
had nothing to act on.

Reachable both as a URL parameter, since isSettingLikeParameter turns any
non-reserved query parameter into a setting, and through the user profile, which
is how the old-analyzer CI configuration reaches it.

Force allow_experimental_analyzer on the request context before the single
executeQuery call so the HTTP path matches the table-function path. The setting
is written in place on the per-request context, deliberately without a context
copy: 6190f34 removed exactly such a copy from this function on review and
switched the class to WithMutableContext. Spelled allow_experimental_analyzer
rather than the enable_analyzer alias, matching the other setSetting sites.

Measured with read_rows from system.query_log on 2 metrics x 16 series x 8
samples, analyzer off via the profile: `a or b` read 880 rows before and 624
after, while `sum(a)`, which shares no subquery, read 288 either way. On a
larger fixture the or, topk and bottomk-or shapes read 1.49x, 1.97x and 2.47x
too many rows. Results are unchanged between the two modes, byte-identical
except for row order on two of ten pairs, which PromQL leaves unordered.

Because results are identical, the regression test asserts on read_rows and on
the analyzer setting recorded for the generated query rather than on results,
which would pass either way. It covers both endpoints and both affected shapes,
plus a control that shares no subquery and a guard against the assertions going
vacuous, and creates the node with use_old_analyzer=True.
Two review findings, both in the new integration test.

The system.query_log read assumed the QueryFinish row exists once the HTTP
response has been received. It need not: finishExecutedQuery flushes the
response in query_finish_callback() and only then calls io.onFinish(), which
writes the QueryLog element, and SYSTEM FLUSH LOGS is not a barrier against a
row that has not been queued yet. The read now waits for the row with
assert_eq_with_retry, the idiom test_prometheus_query_log.py already uses for
the same rows. It waits on count() = 1, so the exactly-one-row guarantee is
kept.

The vacuity guard covered only the `or` shape. Post-fix all measurements run
with the analyzer forced on, so the equality assertions hold by construction
and would survive `topk` silently losing its MATERIALIZED_TABLE mark. `or` and
`topk` acquire that mark through independent code paths, so the guard is now
parametrized over both, each with a read_rows ceiling between its materialized
and unmaterialized measurements: 2.5x a single scan for `or` (624 against 880),
1.5x for `topk` (320 against 576).

Verified with the setting assertion removed on an unpatched binary, which is
what forces the counters to be the only gate: 8 of 10 cases fail on the
counters, up from 6 of 8, with the two new topk cases failing on the ceiling
itself. The two no-shared-subquery controls pass on both arms, as they should.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

Two rounds. Round 1 on 61222bf raised two findings, both about the new test; the source fix
was not changed by either. Round 2 on 6036352 re-reviewed the test changes and the whole
diff cold and found nothing.

Finding Verdict
❌ The new integration test read system.query_log immediately after the HTTP request returned, with no retry. finishExecutedQuery flushes the response in query_finish_callback() and only then calls io.onFinish(), which writes the QueryLog element, so the row can be absent when the request returns and SYSTEM FLUSH LOGS is not a barrier against it. Agreed, fixed. The read now waits with assert_eq_with_retry, the idiom the sibling test in the same directory already uses for the same rows. It waits on count() == 1, not count() > 0, so the exactly-one-row check is kept. Confirmed the retry de-flakes rather than masks: without the fix, 0 of 10 cases fail on the wait and all 10 still fail on the assertion under test.
❌ The topk parametrization had no oracle of its own: with the analyzer forced on, all three of its read_rows measurements are equal by construction, so losing topk's materialization would raise all three together and every assertion would still pass. The anti-vacuity guard covered only the or shape, and the two shapes get the mark from independent code paths. Agreed, fixed. The guard is parameterized over both shared shapes with a per-shape bound taken against a live single-scan measurement, and the mutation arm confirms the two new cases redden on the counters alone.
💡 A note in my own evidence claimed an in-test enable_materialized_cte=0 arm was impossible because setting a Bool to its default does not mark it changed. Disagreed on the mechanism: SettingFieldNumber::operator= sets changed unconditionally and nothing in the assignment chain filters no-op writes. The claim is withdrawn rather than re-derived; nothing in the fix or the guard depends on it.

Also checked and clean, with no finding: the endpoint pair has exactly one SQL-executing site
and the other three endpoints throw NOT_IMPLEMENTED, and the single construction site serves
both configured handler types, so the dynamic-table endpoints are covered too; the forced
setting cannot be refused by readonly = 2 or by a profile constraint; forcing the analyzer
cannot regress a previously-working request, because the table-function path already executes
the same generated SQL analyzer-only; and the test is deterministic under both the
old-analyzer and distributed-plan integration flavors.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. One HTTP request, no randomization, no timing. read_rows from system.query_log is identical across 6 consecutive repeats per shape (uniqExact = 1) after SYSTEM STOP MERGES on the inner samples table.
b Root cause explained? Yes. AS MATERIALIZED is honored by the analyzer only. StoragePrometheusQuery::readImpl builds InterpreterSelectQueryAnalyzer directly, but PrometheusHTTPProtocolAPI::executePromQLQuery passes the generated SQL to executeQuery(), which honors the caller's enable_analyzer. With the analyzer off the shared subquery is rescanned and the enable_materialized_cte default set alongside has nothing to act on.
c Fix matches root cause? Yes. It makes the HTTP carrier agree with the table-function carrier at the point the generated SQL is executed. Not a widened bound, not a masked assertion, not a guard at a symptom site.
d Test intent preserved / new tests added? Yes. No existing test was changed or weakened. New integration test test_query_api_analyzer.py with a read_rows oracle, a no-shared-subquery control, and a per-shape vacuity guard.
e Both directions demonstrated? Yes. 10 new cases pass with the fix, all 10 fail without it, none of them on the query_log wait. The pre-fix failures all hit the analyzer-setting assertion, which fires first, so I additionally ran a mutation arm with that assertion removed to prove the read_rows comparisons redden on their own: 8 failed on the counters (880 vs 624 and 576 vs 320 for the two shapes, 880 against a 288 single scan over a 2.5x ceiling, 576 against 288 over a 1.5x ceiling) and the 2 that passed are the controls, which correctly pass on both arms.
f Fix is general across code paths? Yes. All 4 users of PrometheusQueryToSQL::Converter enumerated. readImpl already forces the analyzer. PrometheusHTTPProtocolAPI is the only violation and is the file's only interpreter call. TableFunctionPrometheusQuery calls getResultColumns() only and never executes SQL. PrometheusRemoteReadProtocol does not use the converter. Metadata endpoints build no Converter, and the handler services one endpoint per request with a per-request context, so the in-place setting cannot reach them.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. Both endpoints (Type::Instant and Type::Range share the fixed function, and both are tested), both shapes that share a subquery (or, topk, plus bottomk ... or measured), both reachability channels (URL parameter and user profile), and two shapes that share nothing as controls. The two shared shapes acquire the MATERIALIZED_TABLE mark through independent code paths, so each carries its own vacuity guard rather than one standing in for the other. No type wrappers apply: this is interpreter selection, not a type predicate.
h Backward compatible? (maintainer-approved exception only) Yes. No setting default changes, so no SettingsChangesHistory.cpp entry. The user's enable_analyzer is untouched for their own queries; only the internally generated PromQL SQL is pinned. Results are byte-identical up to row order, which PromQL leaves unordered. No format or serialization change.
i Invariants and contracts preserved? Yes. The setting is applied on the per-request context immediately before the single executeQuery, which either throws or runs, so there is no partial state and no error path to leak through. Nothing is mutated afterwards. No context copy is introduced, matching 6190f34, which deliberately removed one from this function.

Session id: cron:clickhouse-impl-slot-7:20260811-000600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @vitlibar, could you review this? AS MATERIALIZED is honored by the analyzer only, and the two PromQL entry points disagreed: StoragePrometheusQuery::readImpl builds InterpreterSelectQueryAnalyzer directly while PrometheusHTTPProtocolAPI hands the generated SQL to executeQuery(), so with enable_analyzer = 0 the HTTP endpoints rescanned the shared subquery and the enable_materialized_cte default added in #113772 had nothing to act on.

@vitlibar vitlibar self-assigned this Aug 11, 2026
@nikitamikhaylov nikitamikhaylov added can be tested Allows running workflows for external contributors comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... labels Aug 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4f077cf]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan_ubsan, azure, parallel) FAIL
04625_hash_table_sizes_stats_table_expression_modifiers FAIL cidb IGNORED
04509_hash_table_sizes_stats_table_functions FAIL cidb IGNORED
Stress test (arm_release) FAIL
Logical error: Cannot capture column A because it has incompatible type: got B, but C is expected. (STID: 3408-55d7) FAIL cidb IGNORED

AI Review

Summary

This PR forces the Prometheus HTTP query endpoints to execute their generated SQL with allow_experimental_analyzer = 1 and to enable enable_materialized_cte unless the caller already pinned it, which brings the HTTP path back in line with prometheusQuery / prometheusQueryRange for shared-subquery materialization. The current head also replaces the earlier heavyweight regression with a focused system.query_log assertion while leaving plan-shape coverage to 04816_promql_shared_subqueries_materialized. I did not find an unresolved correctness, safety, or evidence problem in the current code.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.80% +0.10%
Functions 92.00% 92.00% +0.00%
Branches 79.10% 79.10% +0.00%

Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Aug 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 35 queries analysed

This PR only forces the analyzer (and enable_materialized_cte) on the Prometheus/PromQL HTTP handler, plus an integration test — it does not touch the query-execution path that ClickBench or TPC-H exercise. None of the flagged improvements, including the ×8.1 faster reading on TPC-H Q7, can plausibly be caused by this change, so they are downgraded to not-sure as run-to-run/environment variance. The no_change verdict on ClickBench Q18 is consistent with that off-path reasoning.

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 16 not_sure 793 706 -11.0% <0.0001 This PR only forces the analyzer on the PromQL HTTP handler path; it doesn't touch the SELECT execution path Q16 runs, so this -11.0% delta is run-to-run variance.
⚠️ 17 not_sure 556 465 -16.4% <0.0001 The change is confined to the Prometheus/PromQL handler and an integration test; Q17 never executes that code, so the -16.4% shift is not attributable to this PR.
⚠️ 23 not_sure 167 76 ×2.2 faster <0.0001 Q23 is intrinsically noisy and doesn't run the PromQL handler this PR edits, so the ×2.2 faster reading is variance, not a PR effect.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

⚠️ 2 inconclusive

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 7 not_sure 574 71 ×8.1 faster <0.0001 A ×8.1 faster swing on a TPC-H SELECT can't come from a Prometheus-handler analyzer toggle; with no established baseline band this looks like an environment/era difference, not this PR.
⚠️ 8 not_sure 175 81 ×2.2 faster <0.0001 Same off-path story as TPC-H Q7: the PR touches only the PromQL HTTP handler, so this ×2.2 faster delta is not a PR effect.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 5a787011-2820-4039-8842-7da1c022343b
  • MIRAI run: 58a7f505-e632-4c96-adea-1ed9bda9e813
  • PR check IDs:
    • clickbench_1149629_1786676417
    • clickbench_1149642_1786676417
    • clickbench_1149654_1786676417
    • tpch_adapted_1_official_1149660_1786676417
    • tpch_adapted_1_official_1149685_1786676417
    • tpch_adapted_1_official_1149713_1786676417

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6036352

CI is fully finished on this head (0 checks incomplete, Config Workflow and Finish Workflow both SUCCESS, praktika reports 0 dropped jobs, and every one of the 18 skipped jobs carries a genuine skip reason). Four checks are red, none PR-caused: this PR touches only src/Storages/TimeSeries/PrometheusHTTPProtocolAPI.cpp (3 lines forcing the analyzer) and one new integration test, and none of the four failures involves PromQL or TimeSeries query execution.

Check / test Reason Owner / fixing PR
Stress test (amd_asan_ubsan) / Hung check failed, possible deadlock found trunk bug: a cancelled DROP TABLE of a TimeSeries table never returns from DatabaseCatalog::waitTableFinallyDropped, convoying the whole test-database teardown behind the DDL guard a fix task is created (investigating at full effort - fixing PR link to follow on this PR)
Stress test (arm_debug) / Hung check failed, possible deadlock found same signature (is_cancelled: 1, elapsed 3020s, StorageTimeSeries::dropInnerTableIfAny -> waitForTableToBeActuallyDroppedOrDetached -> waitTableFinallyDropped) a fix task is created (investigating at full effort - fixing PR link to follow on this PR)
Stress test (arm_msan) / Hung check failed, possible deadlock found same signature (is_cancelled: 1, elapsed 3041s, identical frames) a fix task is created (investigating at full effort - fixing PR link to follow on this PR)
Stress test (amd_tsan) / Received signal 5 (signal sent by pid 0 from user 0) (STID: 4062-3832) not a ClickHouse fault: SIGTRAP delivered at the dynamic linker's rendezvous breakpoint _dl_debug_state while the stress harness has a debugger attached, reached via libarchive's 7zip reader calling iconv_open -> __libc_dlopen_mode; SignalHandlers.cpp treats it as a fatal signal #114272 (ours, open)

Per-arch reports: amd_asan_ubsan, arm_debug, arm_msan, amd_tsan.

The three hung checks are one event each: the root query is DROP TABLE prometheus; already marked cancelled, and the five DROP DATABASE ... SYNC plus one DETACH DATABASE rows behind it are victims of the same DDL guard, not separate failures. The signature is trunk-wide, not specific to this PR: 69 master occurrences in the last 7 days across 12 check flavours.

Session id: cron:our-pr-ci-monitor:20260811-123000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the hung DROP TABLE of a TimeSeries table (waitTableFinallyDropped): #114302 (external, open).

assert shared < bound * single_scan, (
f"{promql!r} on {path} read {shared} rows against {single_scan} for a single scan, "
f"over the {bound}x ceiling that separates a materialized plan from a rescanning one"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai Fix is right, but this test looks like a big overkill: try to replace it by adding the following test to test_query_api.py:

def test_generated_sql_always_runs_with_analyzer():
    # The SQL generated for PromQL marks shared subqueries AS MATERIALIZED, which only the
    # analyzer honors, so the handler forces the analyzer and enable_materialized_cte
    # regardless of the caller's enable_analyzer. The materialization itself is covered by
    # 04816_promql_shared_subqueries_materialized; here it is enough to check the settings
    # the generated query ran with.
    for path, time_params in (
        ("/api/v1/query", "time=1000"),
        ("/api/v1/query_range", "start=999&end=1002&step=1"),
    ):
        query_id = f"promql-analyzer-{uuid.uuid4()}"
        url = (
            f"http://{node.ip_address}:9093{path}"
            f"?query=post_body_metric&{time_params}&enable_analyzer=0"
        )
        response = requests.get(url, headers={"X-ClickHouse-Query-Id": query_id})
        extract_data_from_http_api_response(response)  # raises unless a success envelope

        node.query("SYSTEM FLUSH LOGS query_log")
        assert_eq_with_retry(
            node,
            "SELECT Settings['allow_experimental_analyzer'], "
            "Settings['enable_materialized_cte'] "
            f"FROM system.query_log WHERE type = 'QueryFinish' AND query_id = '{query_id}'",
            "1\t1\n",
        )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai replace the test after #114409 is merged

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Once #114409 is merged I will add your test_generated_sql_always_runs_with_analyzer to test_query_api.py and delete test_query_api_analyzer.py.

The only coverage that drops is the per-shape read_rows bound, and 04816_promql_shared_subqueries_materialized covers that as you say (it comes back with #114409, which also restores the AS MATERIALIZED marking this test depends on).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced in 4f077cf, essentially as you wrote it. Two changes: import uuid and assert_eq_with_retry were not imported in test_query_api.py, and I passed retry_count=30, sleep_time=1 (matching test_prometheus_query_log.py) because that instance does not install the 300 ms query-log config, so the default 10 s budget sat only 2.5 s above the 7.5 s background flush interval. Measured: the row lands 0.23 s after the flush in 12 of 12 requests, and the longer wait does not mask anything, since the unpatched binary still fails on '1\t1' != '0\t1'.

@nikitamikhaylov

Copy link
Copy Markdown
Member

@groeneai update the PR, merge the master and implement what you was asked.

groeneai and others added 3 commits August 13, 2026 22:23
…ed for in review

Drops the standalone test_query_api_analyzer.py and folds
test_generated_sql_always_runs_with_analyzer into test_query_api.py, as
requested by @vitlibar on the PR. The new test asserts the two settings the
generated query ran with, which is what the source change controls.

The per-shape read_rows liveness bound the standalone test carried is dropped
with it. 04816_promql_shared_subqueries_materialized covers the
materialization itself, and it is back on master with ClickHouse#114409.

Verified both directions on a debug build: the test passes with the fix
(15/15 repeats, and the whole file green under the default, old-analyzer and
distributed-plan integration flavours) and fails without it on the assertion
under test, reporting '1\t1' != '0\t1'.

Co-Authored-By: Claude Fable 5 <[email protected]>
test_query_api.py's instance does not install the 300 ms query-log
configuration the standalone test had, so the default 10 second retry budget
sat only 2.5 seconds above the server's 7.5 second background flush interval.
The response is flushed to the client before the QueryFinish row is queued, so
a flush can precede the row.

Retry for 30 seconds, matching the sibling test in the same directory. The row
appears 0.23 s after the flush in 12 of 12 measured requests, and the wait does
not mask the defect: the unpatched binary still fails on the assertion under
test.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in 4f077cf: merged master (which now carries #114409, so 04816_promql_shared_subqueries_materialized and the enable_materialized_cte block are back) and implemented @ vitlibar's requested test replacement. test_query_api_analyzer.py is gone and his test_generated_sql_always_runs_with_analyzer is in test_query_api.py.

Verified both directions on a debug build: the new test passes with the fix and fails without it on the assertion under test, reporting '1\t1' != '0\t1'. The whole file is green under the default, old-analyzer and distributed-plan integration flavours.

@clickhouse-gh

clickhouse-gh Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 4f077cfe1 with master a55ac986a (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 8e8401256; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 692.04 MiB 689.21 MiB -2.83 MiB (-0.41%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

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

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 4f077cf

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix
task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_asan_ubsan, azure, parallel) / 04625_hash_table_sizes_stats_table_expression_modifiers hash-table prealloc statistics read 0 instead of 520000/650000 (3/3 reruns). Trunk bug, not caused by this PR's diff: 42 unrelated PRs and 7 master hits in 30 days. The build predates the fix: the files #114597 adds are absent at the tested tree a55ac986..., present on master. #114597 (external, merged 2026-08-14 00:51Z)
Stateless tests (arm_asan_ubsan, azure, parallel) / 04509_hash_table_sizes_stats_table_functions same all-zero prealloc signature (3/3 reruns); 41 unrelated PRs and 4 master hits in 30 days; same pre-fix build. #114597 (external, merged 2026-08-14 00:51Z)
Stress test (arm_release) / Logical error: Cannot capture column A because it has incompatible type: got B, but C is expected. (STID: 3408-55d7) trunk bug in FunctionCapture: got Nullable(UInt64), but UInt64 is expected under a lambda with nullable-promoting join settings. 24 unrelated PRs and 4 master hits in 30 days. #111993 (mine, open)

Session id: cron:our-pr-ci-monitor:20260814-043000

@nikitamikhaylov

Copy link
Copy Markdown
Member

@groeneai who broke 04509_hash_table_sizes_stats_table_functions and 04625_hash_table_sizes_stats_table_expression_modifiers? Investigate and suggest a revert.

@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue Aug 14, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Nobody needs a revert; the fix is already on master.

Root cause: LazyReadReplacingFinalSource::buildPlanFromReadingStep built its dedup AggregatingStep with a default-constructed StatsCollectingParams (so max_entries_for_hash_table_stats = 0), and setAggregationHashTableCacheKeys then stamped a cache key onto it. The process-wide statistics cache takes its capacity from whichever query creates it first and is never resized, so when such a query won that race the cache was created with zero capacity: every insert was evicted immediately and every lookup missed, disabling preallocation for the rest of that server's lifetime. That is why both tests read a preallocation count of 0.

My #113333 (merged 2026-08-12 19:00 UTC) is the exposer, not the bug: it stopped keyless aggregations from stamping keys, and those were the callers that used to create the cache first with the real capacity. Reverting it would re-hide the defect instead of fixing it, so I do not suggest a revert.

The actual fix is #114597 (merged today at 00:51 UTC): getHashTableStatsCache no longer creates the cache for a caller that keeps no entries. CIDB since that merge: 04509 668 OK / 0 FAIL, 04625 565 OK / 0 FAIL.

The red build on this PR simply predates it. The newest master commit in that job's tree is 8e84012 (2026-08-13 21:53 UTC), and #114597's merge commit is not in it, which is what my ledger recorded as rule 3b. This branch picks the fix up at its next push.

Merged via the queue into ClickHouse:master with commit 89de3f7 Aug 14, 2026
179 of 182 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 14, 2026
@groeneai groeneai added the groeneai-origin-request PR origin: a maintainer pinged or directed groeneai label Aug 19, 2026
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... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-performance Pull request with some performance improvements 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