Skip to content

Bound the system.text_log scans of test 05061_replicated_database_logs_to_keep_clamp by the test start time - #123652

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05061-bound-text-log-scans
Oct 3, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05061-bound-text-log-scans

Conversation

@groeneai

@groeneai groeneai commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #118103
Related: #103290

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

05061_replicated_database_logs_to_keep_clamp timed out on master in Stateless tests (amd_tsan, s3 storage, parallel, 2/3). No related open issue found.

Its poll helpers cleanups(), lost_warnings() and initializations() count the test's own DDLWorker lines in system.text_log, filtered only by logger_name and message. The table is ordered by (event_date, event_time), so every call reads the whole server log. In that job's query_log, each scan read 1.9-2.2M rows and took 30-178 s under the randomized settings (enable_multiple_prewhere_read_steps = 0, for one, reads message for every row), while every wait loop exited on its first poll: the time went into the scans. The runner's two reruns with the same settings spent 655 s and 656 s in them; five reruns without randomized settings, 1.3-1.5 s.

Change. Take toUnixTimestamp(now()) once before CREATE DATABASE and add event_date >= yesterday() AND event_time >= toDateTime($test_start) to the three scans. Every counted line is logged after CREATE DATABASE, so the counts and the .reference are unchanged. The bound is the test start rather than now() - 600, because text_log grew by about 42k rows per minute in that job, so a ten-minute window would still hold about 420k rows.

Validation (master debug build, Keeper, system.text_log padded to 1.4M rows, the failing job's I/O settings forced):

  • before: each of the 9 scans reads 1.40M rows, the whole table;
  • after: 608 to 10,410 rows per scan, output still matches the reference;
  • negative control (toDateTime(0) as the bound): back to 1.40M rows per scan;
  • 50/50 runs with randomized settings, at most 28k rows per scan.

🤖 Generated with Claude Code


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

Version info

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

…s_to_keep_clamp

The three poll helpers `cleanups()`, `lost_warnings()` and `initializations()`
filtered `system.text_log` only by `logger_name` and `message`. The table is
ordered by `(event_date, event_time)`, so every call read the whole server log.
On MasterCI 2ce7394 (`Stateless tests (amd_tsan, s3 storage, parallel, 2/3)`)
each of those scans read 1.9-2.2M rows and took 30-178 s under the randomized
settings draw, so the test hit the 600 s timeout although every wait loop exited
on its first poll.

Capture the server clock once before the database is created and bound the
three scans to `event_date >= yesterday() AND event_time >= toDateTime($test_start)`.
Every line the test counts is written after `CREATE DATABASE`, so the counts and
the reference are unchanged. The bound is anchored rather than sliding (`now() - 600`)
so a scan reads only what the test itself produced, and a baseline taken earlier
can never count a row that a later poll no longer sees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 3, 2026
@groeneai

groeneai commented Oct 3, 2026

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

Pre-publication review by an independent model (engine: codex; 1 finding; bounded: 1 full pass + 1 fix round + 1 delta recheck).

# Sev Finding Verdict Evidence / action
1 ⚠️ The second-precision bound, taken before the stale-database DROP, could count a same-second row of a preceding invocation on a fixed-database rerun (05061_replicated_database_logs_to_keep_clamp.sh:23) DISAGREE tests/clickhouse-test gives every run, retry and diagnosis rerun a fresh random test_* database and CI passes no --database; on a fixed-database rerun the unbounded master query already counts every earlier invocation.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-10:20261003-044100

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes for the defect: with the master test file every system.text_log poll scan reads the whole table (9/9 scans, 1.40M of 1.40M rows). In CI the timeout repeated 3/3 with the same settings.
b Root cause explained? The poll helpers filter system.text_log only by logger_name and message, outside the (event_date, event_time) sort key, so each call reads the whole log; under TSan and the drawn settings each scan took 30-178 s.
c Fix matches root cause? Yes: the scans are bounded by the sort key to rows written since the test started. No timeout, row limit or randomization change.
d Test intent preserved / new tests added? Yes: same assertions and counts, .reference unchanged. Test-only fix, so no new test.
e Both directions demonstrated? Yes, same forced settings: unfixed 1.40M rows per scan (100%); fixed 608-10,410; negative control (toDateTime(0)) 1.41M. Reference matched in all three.
f Fix is general across code paths? All three system.text_log reads of the test are bounded; it has no other system-log read.
g Fix generalizes across inputs (params/datatypes/wrappers)? The bound is a Unix timestamp, so session_timezone cannot shift it (6 zones in 50 runs); event_date >= yesterday() leaves a day of slack. 50/50 OK with randomized settings.
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? Each poll compares with a baseline taken earlier in the same run; both cover [test_start, now] with a fixed bound, so the later count stays a superset.

Session id: cron:clickhouse-impl-slot-5:20261003-042300

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9832bdd]

Summary: ✅


AI Review

Summary

This PR narrows the three system.text_log polling queries in tests/queries/0_stateless/05061_replicated_database_logs_to_keep_clamp.sh to rows at or after a per-test start timestamp, which matches the timeout root cause described in the PR and keeps the test's assertions unchanged. I did not find a correctness regression in the updated wait/count logic, and the before/after evidence in the PR description is sufficient for this test-only CI fix.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 3, 2026
@groeneai
groeneai requested a review from evillique October 3, 2026 04:57
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 3, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 3, 2026
Merged via the queue into ClickHouse:master with commit e05e495 Oct 3, 2026
149 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 3, 2026
mohammedImad10 pushed a commit to mohammedImad10/ClickHouse that referenced this pull request Oct 5, 2026
04401_http_query_parameters_not_leaked_to_logs bounded its six
system.text_log reads only by `event_time >= now() - INTERVAL 600 SECOND`,
so every read scanned the last ten minutes of the whole server's log. On
the parallel `Stateless tests (arm_binary, ParallelReplicas, s3 storage,
parallel)` server that is ~4.7M rows / ~120 MB of `message` per scan, and
with `remote_filesystem_read_method = 'read'`, `enable_filesystem_cache = 0`
and 1 MiB remote read tasks the five `message LIKE` scans took 97-222 s
each, so the test hit the 600 s timeout (ClickHouse#123752, ClickHouse#122362).

Take `toUnixTimestamp(now())` before the first request and bound all six
reads with `event_time >= toDateTime(test_start)`, as ClickHouse#123652 did for
05061. Every asserted line is logged after that point, so the reference
is unchanged; text_log is ordered by (event_date, event_time), so the
bound prunes the read to the test's own granules. Locally, with 681K rows
in the ten-minute window, a scan reads 381 rows instead of 681,982.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. 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-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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