Skip to content

Add time filters to system log table queries in tests - #96710

Merged
alexey-milovidov merged 35 commits into
masterfrom
fix-system-log-queries
Mar 2, 2026
Merged

alexey-milovidov merged 35 commits into
masterfrom
fix-system-log-queries

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Feb 11, 2026 •

Copy link
Copy Markdown
Member

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)

Summary

  • Add event_date >= yesterday() AND event_time >= now() - 600 filters to all SELECT queries from system log tables in stateless tests (389 files, ~680 changes)
  • Convert message to message_format_string in system.text_log WHERE clauses where the LIKE pattern matches a known format string constant from the C++ source code
  • This prevents tests from scanning entire log tables which can be very large in CI, causing timeouts especially under TSan with randomized max_threads

Time filter changes

All queries from the following system log tables now include time-based filtering:
query_log, text_log, trace_log, metric_log, part_log, query_thread_log, opentelemetry_span_log, zookeeper_log, transactions_info_log, error_log, blob_storage_log, backup_log, query_metric_log, query_views_log, session_log, asynchronous_insert_log, processors_profile_log, s3_queue_log, azure_queue_log, crash_log, asynchronous_metric_log

message_format_string conversions

Where LIKE patterns match known C++ format string constants:

  • 01165_lost_part_empty_partition — "Dropping table with non-zero lost_part_count equal to {}"
  • 01666_merge_tree_max_query_limit — "We have query_id removed but it's not recorded. This is a bug"
  • 02531_two_level_aggregation_bug — "Converting aggregation data to two-level."
  • 02581_share_big_sets_between_*_mutation_tasks_long — "Created Set with {} entries..." and "Got set from cache..."
  • 02935_parallel_replicas_settings — "Disabling 'use_hedged_requests'..." and "Setting 'use_hedged_requests'..."

🤖 Generated with Claude Code

Version info

  • Merged into: 26.3.1.243

alexey-milovidov and others added 2 commits February 11, 2026 23:36
…queries

Add `event_date >= yesterday() AND event_time >= now() - 600` filters
to all SELECT queries from system log tables (`query_log`, `text_log`,
`trace_log`, `part_log`, etc.) in stateless tests. This prevents tests
from scanning entire log tables which can be very large in CI, causing
timeouts especially under TSan with randomized `max_threads`.

Also convert `message` to `message_format_string` in `system.text_log`
WHERE clauses where the LIKE pattern matches a known format string
constant from the C++ source code. This applies to:
- `01165_lost_part_empty_partition`
- `01666_merge_tree_max_query_limit`
- `02531_two_level_aggregation_bug`
- `02581_share_big_sets_between_*_mutation_tasks_long` (both)
- `02935_parallel_replicas_settings`

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Keep both the time filter from our branch and the renamed logger
`processAndOptimizeTextIndexFunctions` from master.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [92449b8]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_debug, AsyncInsert, s3 storage, parallel) failure
03998_distributed_insert_detach_race FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Feb 11, 2026
alexey-milovidov and others added 11 commits February 12, 2026 00:16
- `opentelemetry_span_log` has `finish_date`/`finish_time_us` columns, not
  `event_date`/`event_time` - use `finish_date >= yesterday()` instead
- Update echo test reference files to match new query text with time filters

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96710&sha=2963d320da72f69dcc9055aa87bd8f1e56a6c122&name_0=PR&name_1=Fast%20test

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- `02417_opentelemetry_insert_on_distributed_table`: same `opentelemetry_span_log`
  issue - use `finish_date >= yesterday()` instead of non-existent `event_date`/`event_time`
- `02813_starting_in_text_log`: remove `event_time >= now() - 600` filter since the
  "Starting ClickHouse" message is logged at server boot and can be older than 10 minutes
  in TSan builds

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Resolve merge conflict in 03760_keep_alive_insert_select.sh by taking
  the master version which uses `message_format_string` and `max_threads=0`
- Update 00110_external_sort.reference to match the echoed SQL with time filters

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Conflicts resolved:
- `00974_text_log_table_not_empty.sh`: kept master's CLICKHOUSE_CLIENT approach
  with random settings overrides, added `event_time >= now() - 600` filter
  from our branch
- `03707_parquet_metadata_cache.sql`: accepted deletion (reverted in master)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Resolve merge conflicts in `01661_referer.sh` (combine retry loop with
time filters) and `02835_drop_user_during_session.sh` (combine
`lightweight_deletes_sync` setting with time filters).

Add time filters to `03723_max_insert_block_size_bytes_http.sh` which
was added on master after the branch diverged.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Feb 17, 2026
When there are too many modified tests, the flaky check can exceed
the 2.5-hour job timeout without posting results. This passes
`--global_time_limit` to `clickhouse-test`, calculated as the job
timeout minus elapsed time minus a 5-minute margin. The test runner
then stops gracefully before the hard timeout, allowing the CI to
process and report results for completed tests.

Reference: #96710

Co-Authored-By: Claude Opus 4.6 <[email protected]>
alexey-milovidov and others added 2 commits February 17, 2026 20:01
…rt` tests

The `.sql` files were replaced by `.sh` scripts on master (with retry
loops for `part_log` flushing). Accept the deletion of `.sql` files and
add `event_date >= yesterday() AND event_time >= now() - 600` time
filters to the new `.sh` scripts.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Fgrtue Fgrtue self-assigned this Feb 18, 2026
alexey-milovidov and others added 2 commits February 27, 2026 22:51
…ster

Fix incomplete time filter in `01903_correct_block_size_prediction_with_default`
(memory_2 CTE was missing the filter). Add `event_date >= yesterday() AND
event_time >= now() - 600` to newly merged test files that query system log
tables without filters.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@ClickHouse ClickHouse deleted a comment from CLAassistant Feb 28, 2026
alexey-milovidov and others added 2 commits February 28, 2026 03:35
Address review comments and fix additional missing time filters:
- Add `event_date >= yesterday() AND event_time >= now() - 600` to the
  initial INTERSECT query in `02834_remote_session_log.sh`
- Add time filters to three `session_log` queries in
  `02833_concurrent_sessions.sh` (HTTP, HTTP with session_id, MySQL)
- Add time filters to subqueries in `02161_addressToLineWithInlines.sql`
  and `02796_calculate_text_stack_trace.sql`
- Add time filters to polling loop queries in `02456_async_inserts_logs.sh`,
  `02570_fallback_from_async_insert.sh`, `02714_async_inserts_empty_data.sh`,
  `02725_async_insert_table_setting.sh`, `02908_many_requests_to_system_replicas.sh`,
  `03237_insert_sparse_columns_mem.sh`, `03338_http_compression_profile_events.sh`

Co-Authored-By: Claude Opus 4.6 <[email protected]>
alexey-milovidov and others added 7 commits February 28, 2026 23:27
- Fix `01275_parallel_mv` reference file to include the added time filter line
- Add `finish_date >= yesterday()` to inner subquery in `01455_opentelemetry_distributed`
- Mark `01903_correct_block_size_prediction_with_default` and `01526_max_untracked_memory` as `long`
  (they exceed 180s timeout in TSan/debug/binary flaky check)
- Mark `00974_query_profiler`, `01473_event_time_microseconds`,
  `01569_query_profiler_big_query_id`, `02161_addressToLineWithInlines` as `no-flaky-check`
  (fail due to `trace_log` flush timeout or `TOO_SLOW` with randomized settings in binary flaky check)
- Mark `01455_opentelemetry_distributed` as `no-flaky-check`
  (flaky span count in distributed query tracing)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…nsitive_data_masking` as `no-flaky-check`

`01903_correct_block_size_prediction_with_default` takes 600s+ in TSan even with `long` tag.
`00956_sensitive_data_masking` has pre-existing flakiness at step 5b (masked string not found
in server logs) unrelated to time filter changes.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…flaky-check`

Both tests fail in the binary flaky check due to `trace_log` flush
timeout (180s server-side limit). This is a pre-existing issue unrelated
to the time filter changes in this PR.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…eek_avoiding_when_reading_from_cache` as `no-flaky-check`

`01360` fails due to materialized view on `query_log` capturing extra
entries with randomized settings. `00180` fails with TOO_SLOW when
randomized settings make the S3 INSERT too slow. Both are pre-existing
flakiness issues.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The `.sql.j2` template uses `echoOn`, so the added `system flush logs
query_log;` statement is echoed in the output. The reference file was
missing this line.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The `SYSTEM FLUSH LOGS` statement may or may not appear in `query_log`
depending on timing, causing non-deterministic test output. Filter it out
in the SELECT query instead of including it in the reference file.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-milovidov
alexey-milovidov merged commit 3c36327 into master Mar 2, 2026
143 of 144 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-system-log-queries branch March 2, 2026 03:18
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 2, 2026
pull Bot pushed a commit to Dream-hu/ClickHouse that referenced this pull request Sep 27, 2026
The `system.query_log` checks of `02346_text_index_partially_materialized`
and `02346_text_index_optimize_trivial_count` select the `QueryFinish` row of
an earlier `count()` with `event_time >= now() - 120`. `event_time` is that
query's finish time and `now()` is the check's own start. Between the two the
test runs another index scan and `SYSTEM FLUSH LOGS query_log`, which may
block in `SystemLogQueue::waitFlush` for up to 180 s. Once the gap passes
120 s the row, which is already in the table, is filtered out: the check
returns no row and its expected `1` line disappears from the output. That is
the failure seen on a 346 s run: the two lines after
`---- use text index reader for all parts` were missing, with nothing added.

In the sibling test, `(sum on) < (sum off)` prints `0` when both rows age
out, and passes without measuring anything when only the earlier `on` row
does.

The window was 600 s from ClickHouse#96710 until ClickHouse#111494 narrowed it to 120 s in the
commit that made the test faster by shrinking its dataset, and gave the
sibling the same value. Restore 600 s in all 10 predicates. 600 s is the
per-test timeout (a run still alive after it is killed), so no row a run
writes can fall outside the window of a check in the same run, and it is the
value ClickHouse#96710 uses across the suite. Dropping the condition instead would undo
ClickHouse#96710's pruning of the log scan and, in the Stress and Upgrade jobs where
some workers run every test in one fixed database, remove the only bound
between executions.

A 126 s `sleepEachRow` inserted before the first flush reproduces the exact
diff with the 120 s window (3/3) and passes with 600 s (3/3); a 30 s delay
passes with 120 s. The same delay before the sibling's flush turns its check
from `1` to `0` with 120 s and passes with 600 s. 50 randomized runs of each
test pass, and a paired A/B at `-j 8` shows unchanged per-run time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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