Skip to content

Fix flaky test 03801_materialized_cte#100384

Merged
Algunenano merged 2 commits intomasterfrom
fix-flaky-03801-materialized-cte
Mar 23, 2026
Merged

Fix flaky test 03801_materialized_cte#100384
Algunenano merged 2 commits intomasterfrom
fix-flaky-03801-materialized-cte

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

Fix flaky test 03801_materialized_cte by normalizing non-deterministic node IDs in EXPLAIN QUERY TREE output.

The EXPLAIN QUERY TREE output contains node IDs (id: N, source_id: N) from a global counter that shifts when other queries run in parallel. The test already normalized UUIDs in temporary table and CTE names but did not normalize these node IDs.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100373&sha=4717161518a29a179c942d56728f7220300024d6&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%201%2F2%29

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

The `EXPLAIN QUERY TREE` output contains node IDs (`id: N`, `source_id: N`)
that come from a global counter and are not deterministic when running in
parallel with other queries. The test already normalized UUIDs in temporary
table and CTE names but did not normalize node IDs.

Add a `REGEXP_REPLACE` to replace all `id: <number>` and `source_id: <number>`
patterns with `id: N` and `source_id: N` respectively.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100373&sha=4717161518a29a179c942d56728f7220300024d6&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%201%2F2%29

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Mar 22, 2026

Workflow [PR], commit [03fb8c2]

Summary:


AI Review

Summary

This PR stabilizes flaky test 03801_materialized_cte by normalizing non-deterministic EXPLAIN QUERY TREE node identifiers and pinning optimize_group_by_function_keys to make output deterministic. The changes are scoped to a stateless test and its reference output, align with the stated CI-fix purpose, and I did not find correctness, safety, or performance risks in production code paths.

ClickHouse Rules

Item Status Notes
Deletion logging
Serialization versioning
Core-area scrutiny
No test removal
Experimental gate
No magic constants
Backward compatibility
SettingsChangesHistory.cpp
PR metadata quality
Safe rollout
Compilation time

Final Verdict

  • Status: ✅ Approve

The third query uses `GROUP BY uid, uid + 1`. When `optimize_group_by_function_keys`
is randomly enabled in flaky check, the optimizer removes `uid + 1` (a function
of `uid`), changing the GROUP BY node count. Pin the setting to make output
deterministic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Algunenano Algunenano self-assigned this Mar 23, 2026
@Algunenano Algunenano added this pull request to the merge queue Mar 23, 2026
Merged via the queue into master with commit ddfc1d2 Mar 23, 2026
152 checks passed
@Algunenano Algunenano deleted the fix-flaky-03801-materialized-cte branch March 23, 2026 09:30
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

3 participants