Skip to content

Read system.query_log in default-size blocks in 05620_read_in_order_virtual_row_fixed_key - #132195

Merged
vdimir merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/05620-query-log-default-block-size
Nov 17, 2026
Merged

vdimir merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/05620-query-log-default-block-size

Conversation

@groeneai

@groeneai groeneai commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #130893

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):

Description

05620_read_in_order_virtual_row_fixed_key (new in #130893) hits the 600 s test timeout on master sanitizer builds: amd_msan, amd_tsan, amd_tsan.

The test sets max_threads = 1, max_block_size = 8 for the whole session, as its fixtures need, and that also applies to its read_rows check over system.query_log, which on a CI server holds 0.5-2M rows of other tests' queries. With the default use_query_condition_cache = 1 the reader rounds reads up to whole granules, so the check is fast. The randomizer sets it to 0 in about half the runs, and then the filter runs once per 8 rows. In the failing jobs' own query_log this one query took 383-655 s, over 93% of every failing run, always with use_query_condition_cache = 0.

The check now runs after SET max_block_size = DEFAULT, and the session goes back to 8 right after it (the same idiom as 2bf75d0 and 4ceaaf8). The measured queries run before the reset, so the read_rows they log are unchanged, and .reference is unchanged.

Validation on the master CI binaries with system.query_log filled to 2M rows: on the tsan binary the check ran over 300 s (killed by max_execution_time) before the change and 15-17 s after it, with the whole test at 30-37 s. query_log shows every other statement still runs with max_block_size = 8. 50/50 randomized runs pass on the debug binary.

Reverting #130893 would also stop the timeouts, but it would bring back the wrong row order that it fixes; the slow part is only in the test.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2551-master (included in 26.11 and later)
  • Backported to: 26.10.5.56, 26.9.31.19

…r_virtual_row_fixed_key`

The test sets `max_threads = 1, max_block_size = 8` for the whole session, as
its fixture tables need, and that also applied to its `read_rows` check, whose
two scalar subqueries scan `system.query_log` of the shared CI server (0.5-2M
rows of other tests' queries). With the default `use_query_condition_cache = 1`
`MergeTreeRangeReader` rounds every read up to complete granules, so the 8-row
limit is not honoured there and the check is fast. The randomizer draws
`use_query_condition_cache = 0` about half the time; then 8-row blocks are
honoured, the filter runs once per 8 rows, and on sanitizer builds the check
alone took 383-655 s (over 93% of every failing run, from the failing jobs' own
query_log), hitting the 600 s test timeout on master amd_msan and amd_tsan.

Reset `max_block_size` to its compiled default for the check and set it back to
8 right after it, the idiom of 2bf75d0 (04508) and 4ceaaf8 (05497).
The two measured queries run before the reset, so the `read_rows` they log are
unchanged; every assertion and the `.reference` stay as they are.

Measured on the master 088b6f5 CI binaries with `system.query_log` filled to
2M rows: tsan, use_query_condition_cache = 0, the check ran over 300 s (killed
by max_execution_time) before and 15-17 s after (whole test 30-37 s); query_log
shows every other statement still runs with max_block_size = 8; 50/50
randomized runs pass on the debug binary.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 A SETTINGS max_block_size = DEFAULT clause on the check query would make the restore line unnecessary (05620_read_in_order_virtual_row_fixed_key.sql:96,105) not changed The SET ... = DEFAULT / SET ... = 8 pair is the idiom of 04508 and 05497; query_log shows every statement after the check still runs with max_block_size = 8

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261117-014400

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. With system.query_log filled to 2M rows and --use_query_condition_cache 0, the check runs at max_block_size = 8 with 0.37-0.87 function executions per selected row (release), and on the tsan binary it is killed by max_execution_time = 300 every time. With the cache on: 0.0003 per row, 47 ms.
b Root cause explained? The session max_block_size = 8 reaches the system.query_log check. With use_query_condition_cache = 0 the reader honours 8-row blocks instead of rounding up to granules, so the filter runs once per 8 rows over every other test's queries; on sanitizer builds that exceeds 600 s.
c Fix matches root cause? Yes. Only the check reads with the default block size; the fixtures keep 8. No longer timeout, no tag, no settings clamp.
d Test intent preserved / new tests added? Yes. No assertion or .reference line changes; query_log shows the two measured queries and every statement after the check still run with max_block_size = 8, and a control without the restore line breaks that. Test-only change, so no new test.
e Both directions demonstrated? Yes. tsan binary, same variants: check over 300 s (killed) before, 15-17 s after (whole test 30-37 s). Release binary: 8-row read shape before, granule shape after, in all four variants including the full CI argv of the msan failure.
f Fix is general across code paths? N/A (test-only). The check is the only statement of the test that reads a system table.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). Covered both prewhere shapes of the failing runs and the full CI client argv; 50/50 randomized runs pass.
h Backward compatible? (maintainer-approved exception only) Yes. Test-only, no settings touched.
i Invariants and contracts preserved? Yes. The check compares read_rows logged by queries that run before the reset, and the session goes back to max_block_size = 8 before the next fixture statement.

Session id: cron:clickhouse-impl-slot-40:20261117-010800

@clickhouse-gh

clickhouse-gh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [40bbc0f]

Summary: ✅


AI Review

Summary

PR #132195 temporarily resets max_block_size while checking system.query_log in 05620_read_in_order_virtual_row_fixed_key, then restores 8 before the remaining fixtures. This addresses the reported sanitizer timeout while preserving the measured queries, assertions, and expected output. Reviewed head 40bbc0f7165aecd28d180f5f274389d615b5f753, all prior discussion, the complete test, setting-reset semantics, and linked CI reports. The reported sanitizer comparisons and randomized runs provide adequate evidence for this test-only adjustment. No actionable findings; no local tests were run.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors labels Nov 17, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Nov 17, 2026
@vdimir
vdimir added this pull request to the merge queue Nov 17, 2026
Merged via the queue into ClickHouse:master with commit 9b10750 Nov 17, 2026
386 of 387 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 17, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 17, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 17, 2026
Backport #132195 to 26.10: Read `system.query_log` in default-size blocks in `05620_read_in_order_virtual_row_fixed_key`
clickhouse-gh Bot added a commit that referenced this pull request Nov 17, 2026
Backport #132195 to 26.9: Read `system.query_log` in default-size blocks in `05620_read_in_order_virtual_row_fixed_key`
@clickhouse-gh clickhouse-gh Bot added comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. and removed comp-testing Test content only (no production code). labels Nov 22, 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-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.9-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants