Skip to content

Bound the system.text_log scans in two deduplication log tests - #122525

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:bound-text-log-scan-dedup-log-tests
Sep 27, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:bound-text-log-scan-dedup-log-tests

Conversation

@groeneai

@groeneai groeneai commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #121670
Related: #122432

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

04640_deduplication_log_reattach_no_phantom_blobs and 05258_deduplication_log_alter_window_no_phantom_blobs end with a count() over system.text_log filtered only by level and message. The table's key is (event_date, event_time), so the read selects every granule, and late in a long parallel run it exceeds the max_rows_to_read = 20000000 of tests/config/users.d/limits.yaml. Seen for 05258 in the CH Inc sync check:

Code: 158. DB::Exception: Limit for rows (controlled by 'max_rows_to_read' setting) exceeded, max rows: 20.00 million, current rows: 20.31 million. (TOO_MANY_ROWS) (query 15, line 39)

Change. The two levers the rest of this family uses: event_date >= yesterday() AND event_time >= now() - 600 (as in 9eaf0258dee1b and b8c39c9011b2), so the primary key prunes the read to the last ten minutes, and SETTINGS max_rows_to_read = 0, which #103290 added to scans that already had this bound and still exceeded the limit on log-heavy runs. The error row the check looks for is logged by the test's own ATTACH, well inside the window (these tests are killed after 600 s).

Validation (master e5b8853baca3f debug build, CI config overlay, local MinIO, system.text_log padded to 21M rows):

  • unmodified tests: 6/6 fail with the same TOO_MANY_ROWS (query 13 line 36 of 04640, query 15 line 39 of 05258);
  • fixed tests: 6/6 pass, and 6/6 with 21M rows inside the window, where the check reads 21.02M rows;
  • a corrupted deduplication log is still found: the old and the new check both return 1;
  • 100/100 runs with randomized settings.

About 25 other tests read system.text_log without a bound too; none has failed this way in public CI or been reported from CH Inc sync, so only 05258 and its twin 04640 change here.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.832-master (included in 26.10 and later)

04640_deduplication_log_reattach_no_phantom_blobs and
05258_deduplication_log_alter_window_no_phantom_blobs end with a count()
over system.text_log that filters only on level and message. Neither column
is in the table's key (ORDER BY (event_date, event_time)), so the read
selects every granule, and once a long parallel run has logged more than
20 million rows the query fails with TOO_MANY_ROWS against
max_rows_to_read = 20000000 from tests/config/users.d/limits.yaml (seen in
the CH Inc sync check: "current rows: 20.31 million", query 15, line 39 of
05258).

Apply the two levers already used for this family of tests:
- event_date >= yesterday() AND event_time >= now() - 600, the convention
  of 9eaf025 and b8c39c9, so the primary key prunes the read to
  the last ten minutes;
- SETTINGS max_rows_to_read = 0, as in ClickHouse#103290, because the window alone
  can exceed the limit on a log-heavy run (a time-bounded query of
  00956_sensitive_data_masking failed at 21.28 million rows in the CI of
  PR 103706).

The bound cannot hide a real error row: the row is logged by the test's
own ATTACH shortly before the check, these tests are killed after 600 s
(the runner's --timeout default, which CI keeps; they are not tagged
long), and yesterday() leaves a day of slack against the randomized
session_timezone.

Validated on master e5b8853 with the CI config overlay and a local
MinIO, with a text_log of 21 million rows: the unmodified tests fail 6/6
with the same TOO_MANY_ROWS, the fixed ones pass 6/6, also with 21 million
rows inside the window (their SELECT then reads 21.02 million rows); a
corrupted deduplication log is still counted (base and fixed check both
return 1); 100/100 randomized runs pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Sep 27, 2026
@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; bounded: 1 full pass + 1 fix round + 1 delta recheck).

No findings on the two changed queries. My own review before publication found wording issues only, in the description and the commit message, and those were fixed before the push.

Session id: cron:clickhouse-review-slot-48:20260927-111400

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On a server with the CI config overlay (limits.yaml: max_rows_to_read = 20000000) I padded system.text_log to 21M rows with one INSERT ... FROM numbers(21000000) SETTINGS max_rows_to_read = 0; then clickhouse-test 04640_deduplication_log_reattach_no_phantom_blobs 05258_deduplication_log_alter_window_no_phantom_blobs --test-runs 3 fails 6/6 with Code: 158 TOO_MANY_ROWS at query 13 line 36 (04640) and query 15 line 39 (05258), the final system.text_log checks.
b Root cause explained? The final count() filters system.text_log only by level and message, which are not in its key (event_date, event_time), so it selects every granule (EXPLAIN indexes = 1: 2578/2578) and exceeds the 20M max_rows_to_read once the whole table is larger than that, late in a long log-heavy run.
c Fix matches root cause? Yes. The event_date/event_time bound makes the primary key prune the read to the last ten minutes (10/2578 granules), and a query-level max_rows_to_read = 0 covers runs where the window alone is above 20M, as #103290 did for already-bounded scans. The limit in limits.yaml is unchanged.
d Test intent preserved / new tests added? Yes. With a corrupted deduplication log file and a re-ATTACH, a real Error while loading MergeTree deduplication log row is counted by both the old and the new check (1 and 1). The .reference files are unchanged.
e Both directions demonstrated? Yes, same server and the same 21M-row table: unmodified 6/6 FAIL, fixed 6/6 OK. With 21M rows inside the window the fixed tests still pass 6/6 while their check reads 21.02M rows, and the time bound alone fails there, so both levers are needed. 100/100 randomized runs pass.
f Fix is general across code paths? Both tests of the pair have the same query and both are fixed; their other statements read no large source. Other unbounded system.text_log readers have no failure of this kind in public CI and are not changed.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only change). Settings randomization was live in all 100 runs (7 session_timezone values; yesterday() leaves a day of slack), including parallel replicas.
h Backward compatible? (maintainer-approved exception only) N/A (test-only change, no settings or formats).
i Invariants and contracts preserved? The check still sees every row its own ATTACHes log: these tests are killed after 600 s and these runs take 0.13-0.23 s, so the rows are always inside the ten-minute window. The override is a query-level SETTINGS, scoped to that one statement.

Session id: cron:clickhouse-impl-slot-6:20260927-094900

@clickhouse-gh

clickhouse-gh Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1c9893c]

Summary: ✅


AI Review

Summary

This PR narrows the final system.text_log checks in the two deduplication-log regression tests to the recent indexed time window and adds a query-local max_rows_to_read = 0 override. I did not find a correctness or coverage regression in the current diff: the new predicates match the existing system.text_log test pattern used elsewhere in the tree, and the ten-minute window still covers the ATTACH-triggered error rows these tests are intended to catch.

Final Verdict

✅ No findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 27, 2026
@groeneai
groeneai requested a review from CheSema September 27, 2026 11:43
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 27, 2026
@Algunenano Algunenano self-assigned this Sep 27, 2026
@Algunenano
Algunenano added this pull request to the merge queue Sep 27, 2026
Merged via the queue into ClickHouse:master with commit e5b52dc Sep 27, 2026
172 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 27, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 27, 2026
04909_row_policy_serialized_plan_route failed once in Stateless tests (arm_asan_ubsan, azure,
parallel) with "parallel replicas 0" instead of 2:
https://github.com/ClickHouse/ClickHouse/actions/runs/36327000258/job/108667110916

Both remote replicas had received the plan ("Received query plan" in the server log), but the
initiator's local replica claimed all 17375 marks before either of them announced, so the
coordinator cancelled them ("All ranges for reading has been assigned to replicas. Cancelling
execution for unused replicas. Used replicas: 0"). They logged ExceptionBeforeStart with
QUERY_WAS_CANCELLED_BY_CLIENT, and the oracle counted only QueryFinish rows.

- Count a secondary query by any terminal query_log row, not only QueryFinish.
- Re-run the query, up to three attempts, when fewer than two secondary queries appear: the
  coordinator can also cancel a replica before its query is sent at all, which leaves nothing to
  observe.
- Bound both system log scans to the last ten minutes, as in ClickHouse#122525. Each poll scanned two days of
  text_log, up to 12 s per poll in the failing job, 280 s for the whole test.

Reproduced on a local server with failpoints: parallel_replicas_delay_announcement (replicas
cancelled after they received the plan) turns the old test red with "parallel replicas 0", and
remote_query_executor_cancel_before_send (a replica never contacted) with "parallel replicas 1".
The new test passes both, and removing either change reddens its own case. With the plan replaced
by query text (serialize_query_plan = 0) the arm still fails with 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zvonand pushed a commit to zvonand/ClickHouse that referenced this pull request Oct 8, 2026
The final assertion joined `system.text_log` with no predicate, so the
whole table was read as the join's build side and, on a log-heavy CI
server, exceeded the `max_rows_to_read = 20000000` of
`tests/config/users.d/limits.yaml` (`TOO_MANY_ROWS`, query 35, line 53,
reported from the CH Inc sync check on ClickHouse#100394).

Read `text_log` through a subquery bounded by its primary key to the
last 10 minutes and lift the row limit for that statement, as ClickHouse#103290
and ClickHouse#122525 do. The bound stays inside the subquery so the `LEFT JOIN`
keeps the queries that log no row store line. The joined rows are
written by the test's own queries, and the test is killed after 600 s,
so they are always inside the window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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. groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet 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