Skip to content

Make stateless tests parallel-safe with per-test isolation - #110015

Open
fm4v wants to merge 1 commit into
masterfrom
no-parallel-groups-runner
Open

fm4v wants to merge 1 commit into
masterfrom
no-parallel-groups-runner

Conversation

@fm4v

@fm4v fm4v commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

This PR makes stateless test execution more parallel-safe through per-run identities, per-test user_files sandboxes, no-parallel concurrency groups, self-parallel control, and targeted rewrites of tests that previously depended on fixed global state.

The cache-scoping FOR TABLE feature is intentionally not part of this PR. The 43 tests that had depended on it, plus three additional tests that used the scoped syntax, are kept with plain no-parallel tags and documented reasons, preserving their sequential isolation.

The remaining migration uses unique per-run names, isolated files, query-cache tags, filtered log assertions, and documented serialization groups where those mechanisms are sufficient.

Original CI context: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=70fb487d370029230f4968a6ea70a8ca86d9ae96&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Make more stateless tests safe to run in parallel.


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

@clickhouse-gh

clickhouse-gh Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [31303aa]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_asan_ubsan, flaky check) FAIL
02346_text_index_preprocessor FAIL cidb
01593_concurrent_alter_mutations_kill FAIL cidb
01913_exact_rows_before_limit FAIL cidb
04103_deltalake_parquet_metadata_cache FAIL cidb
Stateless tests (amd_debug, flaky check) FAIL
04103_deltalake_parquet_metadata_cache FAIL cidb
03642_system_instrument_profile FAIL cidb
03350_alter_table_fetch_partition_thread_pool FAIL cidb
03642_system_instrument_dispatch_bug FAIL cidb
01593_concurrent_alter_mutations_kill FAIL cidb
Too many test failures FAIL cidb
Stateless tests (amd_binary, flaky check) FAIL
03642_system_instrument_profile FAIL cidb
04103_deltalake_parquet_metadata_cache FAIL cidb
Scraping system tables FAIL cidb
Stateless tests (amd_debug, parallel) FAIL
00965_logs_level_bugfix FAIL cidb
Stateless tests (amd_tsan, s3 storage, targeted) FAIL
01593_concurrent_alter_mutations_kill FAIL cidb

AI Review

Summary

This PR moves stateless tests into parallel execution using per-run fixtures, file sandboxes, and concurrency groups. Most previously reported races and weakened assertions are addressed. Three concerns remain: worker recovery can deadlock, full flaky checks still overlap fixtures that are unique only per file, and server-wide primary-key loading loses its regression coverage. Reviewed head: 31303aa4e876087e56cc2b64a4ff447e9210760f.

Missing context / blind spots
  • ⚠️ Full stateless jobs for this head were still queued when reviewed. Local validation covered the scheduler recovery probe, not a running server or the full parallel/flaky suite; completed results would close that execution gap.
Findings

❌ Blockers

  • tests/clickhouse-test:6855: worker failure must stop the run without acquiring an abandoned worker-owned lock. The reaper skips scheduler cleanup for a failed worker, but still takes the same lock for a normally exited worker. If another worker died holding it, the parent blocks indefinitely. The focused probe reproduced both orderings: normal worker first blocks before failure detection; failed worker first sets the stop flag and then blocks on normal-worker cleanup. Remove parent-side acquisition of worker-owned scheduler locks during reaping, or make scheduling survive worker death. Existing thread.

⚠️ Majors

  • ci/jobs/functional_tests.py:264: full flaky checks still pass only --flaky-check, so converted tests with fixed server-global fixtures overlap their own repetitions. For example, 02483_substitute_udf_create.sql can drop another copy's 02483_plusone; 02494_query_cache_bugs.sql can clear another copy's cache tag before its snapshot; 03206_wasm_module_manage.sql and 03661_local_can_start_with_server_directory.sh similarly share modules/functions and listener ports. The TAG exemption in various_checks.sh:222 also accepts those fixed shared tags. Enable --no-self-parallel for full flaky checks, or isolate/serialize all remaining fixtures, with the safety gate enforcing that choice. Existing execution thread, existing gate thread.
  • tests/queries/0_stateless/03202_system_load_primary_key.sql:40: replacing the table-less SYSTEM LOAD PRIMARY KEY removes the only runtime test of server-wide loading. Its catalog-iteration branch is distinct from table-scoped loading; making that branch a no-op would now pass every remaining load test. Preserve an isolated global-load assertion after unloading both fixtures, checking that both regain primary-key memory. New inline finding.
Tests
  • ⚠️ Exercise worker death while holding the scheduler lock together with a normally exited worker, in both reaping orders; require bounded failure/shutdown.
  • ⚠️ Verify full flaky checks serialize repetitions that use fixed fixtures, or prove their per-run isolation.
  • ⚠️ Retain observable coverage of table-less SYSTEM LOAD PRIMARY KEY.
Final Verdict

Status: ❌ Block. Prevent the recovery deadlock, make full flaky execution safe for the remaining fixed fixtures, and preserve server-wide primary-key load coverage.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jul 10, 2026
@mintlify

mintlify Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Oct 14, 2026, 6:19 PM

fm4v added a commit that referenced this pull request Jul 11, 2026
…::clearTable

The previous fix (a37fd15) covered the four prefix-eviction call
sites but missed clearTable, which also passes a lambda to remove on
a cache keyed by UInt128. Use the same explicit std::function pattern.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=4eb73d7d3388494c644fd1f745a7070a8d7f913a&name_0=PR&name_1=Fast%20test
PR: #110015
fm4v added a commit that referenced this pull request Jul 11, 2026
Commit 4eb73d7 tagged three tests with `no-parallel:remote-databases`
and extended the style-check allowlist, but missed the runner's own
`NO_PARALLEL_GROUPS` set, so `clickhouse-test` aborted on startup with
`TestException: Unknown no-parallel concurrency group: remote-databases`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=a1111845ace77c5267240ec35a6b59c04503f297&name_0=PR&name_1=Fast%20test
PR: #110015
fm4v added a commit that referenced this pull request Jul 11, 2026
Test-side fixes:
- Sandbox-relative `file()` paths: 15 `.sh` tests wrote data into the per-test
  `$CLICKHOUSE_USER_FILES_UNIQUE` sandbox but still referenced bare relative
  names in queries, which the server resolves against the `user_files` root;
  all such references now carry the `${CLICKHOUSE_TEST_UNIQUE_NAME}/` prefix
  (also covers `no-fasttest` tests that would have failed later in Stateless).
- Global-entity cleanup: `03231`, `03353`, `03636` never dropped their
  users/roles/quotas and now trip the runner's leak check; `02883` dropped
  `$u2` twice instead of `$u3`.
- Comment attachment in `query_log`: the leading comment block of a `.sql`
  file is part of the first query's logged text, so `query LIKE 'SELECT ...%'`
  filters in `02385` and `03272` never matched; both now find their queries by
  a per-query `log_comment` setting.
- `00693` compared consecutive server-wide counts of `system.tables` /
  `system.columns`, which is racy under parallel DDL; the counts are now
  scoped to `currentDatabase()` over a fixed set of own tables.
- `02494_query_cache_user_quotas*`: `query_cache_max_entries` /
  `query_cache_max_size_in_bytes` are per-user quotas counted across the
  whole server-wide query cache and all tests run as the same user, so these
  two tests got their `no-parallel` tag back with a documented reason.
- `03444`: without a leading `-- Tags:` line the client does not skip a
  leading comment block (`getTestTagsLength`), the block glues to the first
  query, and its parse-time `clientError` hint is not honored (the hint
  search after a parse exception covers only the first line); the obsolete
  leading comments are removed. Verified against a master binary.
- Stale references updated for `03460` (echoed query text) and `02101`
  (identifier no longer needs backquotes).
- `02950` counts shard sub-queries in `query_log`, which log
  `current_database = 'default'` on localhost clusters; the filter is now
  `current_database IN (currentDatabase(), 'default')`.

Server-side fix:
- `MergeTreeDataPartWide::removeMarksFromCache` enumerated serialization
  streams, which for columns with data-dependent substreams (`Dynamic`,
  `JSON`) misses the variant streams without a deserialization state, so
  `SYSTEM CLEAR MARK CACHE FOR TABLE` left their marks cached (seen as a
  wrong `FileOpen` count in `03198`). It now iterates `checksums.files`,
  which lists the mark file of every stream actually present in the part.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=6b35b72fc6a86e7f63fcdd1276c4bf189310046b&name_0=PR&name_1=Fast%20test
PR: #110015
fm4v added a commit that referenced this pull request Jul 11, 2026
…erver-wide user RESTORE

- The databases `shard_0`/`shard_1` are shared fixtures hardcoded by the
  `test_cluster_two_shards_different_databases` cluster config, so parallel
  tests cannot rename them. Nine untagged tests still dropped these databases
  at start or end, destroying them for every concurrently running test (this
  is what failed `02915_move_partition_inactive_replica` and
  `01231_distributed_aggregation_memory_efficient_mix_levels`). All nine now
  only `CREATE DATABASE IF NOT EXISTS` and create/drop their own
  uniquely-named tables inside; generic table names (`tbl`, `t_local`,
  `t_sus`, `v_sus`, `test`) got per-test suffixes. `01152`'s unscoped
  `SHOW TABLES FROM shard_N` is scoped by `LIKE` to stay deterministic.
- `03231_restore_user_with_existing_role` and
  `04027_restore_access_entities_with_current_grants` get their `no-parallel`
  tag back: `BACKUP TABLE system.users` snapshots every user on the server
  and `RESTORE ALL` recreates them all, changing the UUIDs of users created
  by concurrent tests and breaking their in-flight sessions (this is what
  failed `03748_async_insert_reset_setting`, which is untouched and almost
  never flaky on master). The tests' own header comments already explained
  the constraint; the migration untagged them regardless.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=a9951d3b2349cb32453cfbcccfbd6e624bab7a55&name_0=PR&name_1=Fast%20test
PR: #110015
fm4v added a commit that referenced this pull request Jul 11, 2026
- `02024_merge_regexp_assert`: `merge(REGEXP('.'), '^t$')` scans every database on the
  server, so a concurrent test's table named `t` changes the query outcome (`REGEXP`
  requires a literal, so the pattern cannot be scoped to `currentDatabase()`).
- `02494_query_cache_user_quotas*`: reverted to the master version (unscoped
  `SYSTEM CLEAR QUERY CACHE`, unfiltered counts) with the `no-parallel` reason spelled
  out. The tag-scoped migration failed even when running solo: the per-user quota counts
  entries across the whole query cache, including entries left by earlier tests, so the
  quota was already exhausted before the test inserted anything.

Not addressed here, watch for recurrence: `02346_text_index_header_cache` (one
unexplained header-cache eviction between two queries; the label/prefix scheme rules
out cross-table matches) and `04337_quorum_insert_honors_time_limit` (quorum wait
aborted with `UNKNOWN_STATUS_OF_INSERT` under load, 1 failure in 64k runs on record).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=a4544f5b3d0e5728cece863b4a69f500bdb79499&name_0=PR&name_1=Fast%20test
PR: #110015
fm4v added a commit that referenced this pull request Jul 12, 2026
Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=4148e9cb9aef4cd42def363396465967f2a36430&name_0=PR&name_1=Stateless+tests+%28arm_binary%2C+parallel%29
PR: #110015

Three families and four individual fixes:

1. user_files sandbox relative paths (5 tests): the tests write data into
   the per-test sandbox `$CLICKHOUSE_USER_FILES_UNIQUE/<file>` but called
   `file('<file>')` with a bare relative name, which the server resolves
   against the global `user_files` root -> `CANNOT_STAT` / empty globs.
   Prefix the paths with `${CLICKHOUSE_TEST_UNIQUE_NAME}/`:
   `02240_tskv_schema_inference_bug`,
   `02242_arrow_orc_parquet_nullable_schema_inference`,
   `02247_names_order_in_json_and_tskv`,
   `02459_glob_for_recursive_directory_traversal`,
   `02286_mysql_dump_input_format` (dump4-dump15 were missed by the
   migration). An audit of all other sandbox-using tests found no more
   instances.

2. Stale references after scoping cache clears (3 tests): the queries were
   changed to `SYSTEM CLEAR FILESYSTEM CACHE '<name>'` but the `-- { echo }`
   references still had the unscoped form: `00170_s3_cache`,
   `02240_filesystem_cache_bypass_cache_threshold`,
   `02240_filesystem_query_cache`.

3. `02226_filesystem_cache_profile_events`: the cache of the `azure_cache`
   storage policy is registered under the disk name `cached_azure`, so
   `SYSTEM CLEAR FILESYSTEM CACHE 'azure_cache'` failed with BAD_ARGUMENTS.
   Map the policy name to the cache name.

4. `01532_execute_merges_on_single_replica_long`: restore the fixed
   ZooKeeper path. The merging replica is picked by
   `hash(zookeeper_path + part_name)`, and the reference asserts which
   replica merges each part; `{database}` in the path randomized the
   assignment. The path is unique to the test and `--no-self-parallel`
   serializes flaky-check copies, so it stays parallel-safe.

5. `02346_text_index_direct_read`: scope the `system.text_log` scan to this
   test's queries via `system.query_log` - concurrent tests' text-index
   queries also log `Added:` messages and leaked into the last-8 window.

6. `00140_rename`: replace `CREATE TABLE ... CLONE AS test.hits` with a
   minimal local fixture. `CLONE` inherits the source storage, which is
   static (read-only) when the stateful tables are attached from a web
   disk, and the internal `ATTACH PARTITION` fails with
   TABLE_IS_PERMANENTLY_READ_ONLY. Only the two counters the assertions
   read are copied; reference values are unchanged.

7. `03710_parallel_alter_comment_rename_selects`: scope the
   `system.databases`/`system.tables` scans to the test's own databases.
   An unfiltered scan iterates every database, including concurrent tests'
   remote databases with unreachable hosts, whose connection errors failed
   the scan (exit code 35). The pushed-down predicate keeps the
   rename/comment/scan lock interplay the test hunts.
fm4v added a commit that referenced this pull request Jul 12, 2026
Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/110015/8ced04efa4ab1e61d6f67c41658b41fff335016d/result_pr.json
PR: #110015

- Style check: four tests merged from master document their `no-parallel`
  reason as `# no-parallel: ...`; the check requires the `Tag no-parallel:`
  form. Convert the comments (the tags themselves are legitimate: global
  `PAUSEABLE_ONCE` failpoints).

- Fast test: `04249_query_condition_cache_fine_grained_granules` asserts
  that the query condition cache entry written by the first query is still
  present for the second one. The intervening `SYSTEM FLUSH LOGS` plus
  `query_log` scan opened a seconds-long window under the parallel pool, in
  which concurrent tests' cache writes could evict the entry (release-build
  entries now also store the condition text, increasing churn), producing
  `0 100` instead of `1 1`. Run the two queries back-to-back and do both
  `query_log` checks afterwards; the reference is unchanged.
fm4v added a commit that referenced this pull request Jul 12, 2026
…ows, restore no-parallel on 00170

Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/110015/6e829e5ca1b671fdf00ae6968a300846fbc93368/result_pr.json
PR: #110015

- `02578_parameterized_rename_queries` (amd_tsan, flaky check) and
  `01224_no_superfluous_dict_reload` (arm_binary, parallel): unfiltered or
  name-only `system.tables` scans iterate every database, so concurrent
  tests' databases fail the query - a remote database with an unreachable
  host (`ALL_CONNECTION_TRIES_FAILED`) in the first case, a readonly table
  (`DATABASE_ACCESS_DENIED`) in the second. Scope both scans with a
  database predicate, which is pushed down before iteration.

- `03229_query_condition_cache_profile_events` (arm_binary, parallel) and
  `02226_filesystem_cache_profile_events` (arm_asan_ubsan, targeted):
  cache-hit assertions raced with concurrent cache traffic - the flush plus
  query_log scan between the populating query and the hitting query is a
  seconds-long LRU eviction window (the shared s3_cache is 200 MiB; QCC
  entries now also store condition text). Run the profiled queries
  back-to-back and do all query_log checks afterwards, like
  04249_query_condition_cache_fine_grained_granules. In 02226 also keep the
  policy-to-cache-name mapping from the previous commit.

- `00170_s3_cache` (amd_tsan, parallel: "Server died"): restore the
  `no-parallel` tag. The server did not die - it was stopped normally at
  job end; the report came from this test exceeding the 180 s per-test
  budget (about 100 s alone under TSan, more in a loaded pool), whose
  timeout hung-check cascade aborted the run. Master also keeps this test
  `no-parallel` for heaviness; the scoped filesystem-cache clear stays.

- `02241_filesystem_cache_on_write_operations` timed out once on
  arm_binary (reruns passed); left unchanged as a transient, watching.
fm4v added a commit that referenced this pull request Jul 12, 2026
Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/110015/4a1c3532d1f/result_pr.json (Fast test at 4a1c353)
PR: #110015

The previous commit placed an explanatory comment directly above the second
profiled query. In `.sql` tests a comment is sent as part of the following
statement, so the logged query text no longer matched the exact-text
`query = '...'` filter in the check, which returned zero rows. Attach the
comment to the `SYSTEM FLUSH LOGS` statement instead, whose text nothing
matches. (`04249` was unaffected by the same restructure because it filters
by `log_comment`.)

Also seen in that run: `01165_lost_part_empty_partition` failed with
`NOT_INITIALIZED` when re-creating a replicated table on a just-dropped
ZooKeeper path - a pre-existing low-rate flaky unrelated to this branch
(the test is unchanged here and fails sporadically on other PRs).
fm4v added a commit that referenced this pull request Jul 12, 2026
…eration, isolate 02226 caches, misc

Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/110015/9b93b8fe75d544d6d86be589410072aec1e618d2/result_pr.json
PR: #110015

- `DatabaseMySQL::getTablesIterator` no longer throws on connection failures
  and serves the (possibly stale or empty) local cache, mirroring
  `DatabasePostgreSQL::getTablesIterator`. Enumeration - `system.tables` /
  `system.columns` scans, completion suggestions, and unknown-table-name
  hints (the default `getAllTableNames` routes through the iterator) - used
  to fail arbitrary concurrent queries while a remote database with an
  unreachable endpoint existed. This is what failed
  `01502_long_log_tinylog_deadlock_race` (amd_tsan, flaky check): its
  expected `UNKNOWN_TABLE` errors turned into `ALL_CONNECTION_TRIES_FAILED`
  while the hint generator iterated a concurrent test's `fake_db`. New test
  `04512_mysql_database_unreachable_host_enumeration` covers it.

- `02226_filesystem_cache_profile_events` (arm_asan_ubsan, targeted): give
  the test its own inline cache disks over the same three backing stores
  (s3_disk / local_disk / azure). The shared `s3_cache` is 200 MiB and is
  thrashed by concurrent tests - this round every read bypassed the full
  cache (source reads with zero cache writes), previous rounds saw evictions
  between queries. Assertions about hit/miss sequences need a cache nothing
  else touches.

- `01010_pmj_right_table_memory_limits` (arm_binary, parallel, reproducible):
  pin `collect_hash_table_stats_during_joins = 0`. A size hint from the
  server-global hash-table statistics cache enables exact preallocation and
  keeps the join's peak memory under the 32 MB limit the test expects to
  exceed; once the cache is seeded the test fails deterministically.

- `02494_query_cache_ttl_long` (arm_binary, parallel): restore `no-parallel`.
  The test asserts a stale query-cache entry stays visible until refreshed,
  but any concurrent query-cache insert evicts stale entries cache-wide -
  tag scoping cannot help.

- Add `no-flaky-check` to four heavy tests that exceed the 180 s per-test
  budget when the flaky/targeted check reruns them on sanitizer/debug builds
  with fresh random settings: `00077_log_tinylog_stripelog`,
  `01111_create_drop_replicated_db_stress` (up to ~6 min on sanitizers),
  `02346_text_index_hits`, `03791_rmt_watches`.

Left unchanged (single-shot races, clean reruns, watching):
`03254_prewarm_mark_cache_rmt` (prewarm-on-attach race),
`01501_cache_dictionary_all_fields`, `02240_filesystem_query_cache`,
`04004_dist_index_analysis_poisons_query_condition_cache`,
`01338_long_select_and_alter`, `03312_line_numbers`,
`02481_async_insert_dedup_token`, `01165_lost_part_empty_partition`.

struct Entry
{
#if defined(DEBUG_OR_SANITIZER_BUILD)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember I added the ifdefs long time ago. Why are the extra members no longer considered too expensive for release builds?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only table_uuid moved out of the DEBUG_OR_SANITIZER_BUILD block. The expensive String fields (part_name / condition) and condition_hash are still debug-only.

The release-build change here is just the fixed-width UUID, because SYSTEM CLEAR QUERY CONDITION CACHE FOR TABLE ... needs a stable per-entry table identifier and the cache key is a one-way hash, so there is no other way to recover the owning table from an entry during eviction.

fm4v added a commit that referenced this pull request Jul 16, 2026
…g-test timeouts

Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/110015/aa6cb50e5315ea40ced929ea0de37d8696f6ad7c/result_pr.json
PR: #110015

- clickhouse-test: `long` tests get `max(--timeout, 600)` instead of the flat
  180s default. `02241_filesystem_cache_on_write_operations` (already `long`,
  killed at exactly 180s on arm_binary under parallel load) and other `long`
  tests keep the pre-parallelization budget that the 600s master default gave
  them. The worker SIGALRM window scales accordingly.

- The `remote-databases` concurrency group is dissolved; its members (04512,
  04210, 04507, 03525) go back to plain `no-parallel`. While an unreachable
  remote database exists, any concurrent query that enumerates databases
  (`system.tables`/`system.columns` scans, name hints) triggers connection
  attempts whose Error-level log lines (`mysqlxx::Pool`, connection-failure
  logging) are attributed to that query and forwarded to its client. This
  failed 00722_inner_join and 01602_temporary_table_in_system_tables
  (arm_binary, parallel) and 00693_max_block_size_system_tables_columns
  (amd_debug, flaky check, 4x) with "having stderror". A group cannot help:
  the victims are arbitrary ungrouped tests.

- 02911_row_policy_on_cluster: converted to .sh; the row policy now targets the
  test's own database with unique entity names instead of `default.*`. The old
  policy denied `default.*` to every other user while it existed, which broke
  the XML-dictionary tests 00950_dict_get and 01501_cache_dictionary_all_fields
  (amd_msan, flaky check) with "Table default.ints/decimals has row policies,
  but none of them are for the current user".

- 02252_jit_profile_events: back to plain `no-parallel`. The compiled-expression
  cache is server-global and keyed by function signatures, not query text; any
  concurrent query JIT-compiling a matching signature (e.g. three `avg(UInt64)`
  aggregates, `compile_aggregate_expressions` is default-on) pre-warms the entry
  and `CompileFunction` drops to 0 (5x amd_tsan + 1x amd_debug flaky checks).

- 03985_prewarm_index_mark_cache: back to plain `no-parallel`. The stateless
  mark cache is only 128 MiB (`small_caches.xml`); concurrent tests push it
  above `mark_cache_prewarm_ratio` (prewarm skips parts) or evict prewarmed
  entries, flipping "after prewarm on restart" from 0 to 1.

- 02286_drop_filesystem_cache: back to plain `no-parallel`; exact per-file cache
  entry counts are sensitive to load-dependent segmentation (1 -> 2 entries on
  arm_binary, parallel).

- 03652_threads_count_insert: pin `use_concurrency_control = 0` instead of
  relying on an idle server; concurrency control grants fewer thread slots under
  concurrent load, which turned `peak_threads_usage` 7 into 4 (amd_debug,
  parallel). The test stays parallel.

- 02962_system_sync_replica_lightweight_from_modifier: tag as `long` (10
  replicas, wall-clock-bounded insert/sync/drop loops) - it timed out at the
  180s cap in the amd_asan_ubsan flaky check.

- 00090_thread_pool_deadlock: restore `no-parallel`. It deliberately saturates
  the global thread pool; run in parallel it starved concurrent tests into
  `CANNOT_SCHEDULE_TASK` failures (amd_tsan) and contributed to the global
  time-limit "Server died" verdicts - both such runs show a cleanly alive
  server, just a suite stalled by contention.

- test_mysql_database_engine/test_mysql57_database_engine test_restart_server:
  enumeration of a MySQL database with an unreachable endpoint no longer throws
  (it serves the empty post-restart cache, consistent with PostgreSQL), so
  assert the tolerated behavior instead of expecting an exception.
fm4v added a commit that referenced this pull request Jul 17, 2026
…extras

Addresses the review comment from @rschu1ze on #110015: the extended Entry
members were considered too costly for release builds when the ifdefs were
introduced, and this branch had dropped the guard entirely.

The guard is restored for the costly members - `part_name` (String),
`condition` (String) and `condition_hash` - in Entry, EntryWeight, the write
path and system.query_condition_cache (columns are again debug/sanitizer-only,
docs updated, 03460 gets its `no-release` tag back).

Only `table_id` stays in release builds: `clearTable` (backing
`SYSTEM CLEAR QUERY CONDITION CACHE FOR TABLE`) selects a table's entries by
it and cannot use the key (a one-way CityHash128), and the parallel-safe tests
scope their `system.query_condition_cache` scans by the `table_uuid` column.
Unlike the strings it is a fixed 16 bytes per entry.

PR: #110015
fm4v added a commit that referenced this pull request Jul 17, 2026
Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=c75dc707c9b0862a38a28229dc200e2e8bc670fb&name_0=PR&name_1=Style%20check
PR: #110015

Tests that arrived with the master merge, checked against this branch's rules:

- 04338_query_condition_cache_topk_part_set_invalidation: scope the two global
  `SYSTEM CLEAR QUERY CONDITION CACHE` to `FOR TABLE tab` - every assertion in
  the test is a per-query `log_comment` ProfileEvents check on `tab`, so the
  scoped clear preserves the semantics and keeps the test parallel-safe.
- 03814_system_unload_dictionary: document the `no-parallel` reason
  (`SYSTEM UNLOAD DICTIONARIES` unloads every dictionary on the server).
- 04000_empty_part_stale_tmp_dir, 04401_replicated_database_ddl_status_finished_node_missing:
  reformat the existing reason comments to the `Tag no-parallel:` form the
  style check recognizes.
- 04538_materialized_view_comment_implicit_alias{,_message}: drop `no-parallel`
  entirely - both tests only touch objects in their own database and filter
  `system.tables` by `currentDatabase()`.
fm4v added a commit that referenced this pull request Jul 17, 2026
The style check evaluates the PR after merging current master, which added test 03908 with a reason comment that does not use the recognized prefix. Add the upstream test version with the required `Tag no-parallel:` form so the synthetic merge contains only the comment fix.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=bbc75fa974e3359dc121a0d9f4938e7bde490a7a&name_0=PR&name_1=Style%20check
PR: #110015
fm4v added a commit that referenced this pull request Jul 19, 2026
Resolve the style-check conflict by retaining the scoped cache-clear and grouped `no-parallel` checks together with the new global async-insert flush check from `master`. Update newly merged tests to use the required `Tag no-parallel:` reason prefix.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110015&sha=da159ca3a25e939187f01f71b3b26847958c9fdc&name_0=PR&name_1=Style%20check
PR: #110015
@fm4v

fm4v commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110015&sha=6854c298905d73d6fa05374856c307c62d80e2d9&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

05210_lightweight_update_materialized_cte_in_ignore fails with UNKNOWN_TABLE (Unknown table expression identifier '_materialized_cte_c_...' while executing Remote) in Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) on master and on 20+ PRs since 2026-10-11. It may be covered by #123121.

@groeneai

Copy link
Copy Markdown
Collaborator

Not caused by this PR. The fix is #123121 (mine, open).

This run fails in query 26 on the IN subquery sent to the other replicas, which reads _materialized_cte_c_*. That is the parallel replicas race from #112642 that #123121 fixes: the initiator's local plan waits for the materialized CTE only in its own branch, so the query sent to the other replicas can run before the temporary table exists. Since 2026-10-08 the test failed on 19 master commits and 105 PRs. #123121 is mergeable and has been waiting for review since 2026-09-30 (requested from @ novikd and @ devcrafter).

@fm4v

fm4v commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110015&sha=6854c298905d73d6fa05374856c307c62d80e2d9&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20AsyncInsert%2C%20s3%20storage%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

03822_variant_distinct_filter (not touched by this PR) hit the 300 s timeout in Stateless tests (arm_binary, AsyncInsert, s3 storage, parallel): the client was stuck in ClientBase::executeMultiQuery -> receiveResult, i.e. in the batch of 80 INSERT INTO test_variant_distinct ... statements sent through one clickhouse-client -n under async inserts. Reruns passed; it is the first failure of this test in CIDB in 60 days.

@groeneai

Copy link
Copy Markdown
Collaborator

Not a hang. Under async inserts the 80 setup INSERTs are slow, and the 300 s cap in this PR turns that into a failure.

  • The job's query_log shows 63 of the 80 INSERTs finished, each in 3.5-5.0 s (299.6 s in total). The 64th was still waiting when the test was killed.
  • In the AsyncInsert jobs each INSERT waits for its flush (wait_for_async_insert=1), and tests/config/users.d/timeouts.xml sets async_insert_busy_timeout_ms=5000. The adaptive busy timeout is tracked per queue shard (key.hash % pool_size, src/Interpreters/AsynchronousInsertQueue.cpp:736), so inserts from other tests on the same shard can push it up to 5000 ms. Here the very first INSERT already waited 5.0 s (shard 8).
  • This happens on master too. In the last 14 days, 54 of 1106 runs of this test in this job took longer than 300 s (5 on master, max 406 s). All of them passed because the --timeout on master is 600 s. Other tests also take longer than 300 s in the AsyncInsert parallel jobs, for example 01821_join_table_race_long (63 runs), 01601_accurate_cast (53) and 01019_alter_materialized_view_atomic (38).

Fix for 03822: run the setup INSERTs with async_insert = 0. The test needs one Memory block per INSERT anyway, and the concurrent SELECT part stays as it is. I'll open it as a separate PR and link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix for 03822_variant_distinct_filter is #125201: the 80 setup INSERTs now run with --async_insert=0.

Comment thread tests/clickhouse-test Resolved
Comment thread tests/clickhouse-test Resolved
Comment thread tests/clickhouse-test Resolved
Comment thread tests/clickhouse-test Outdated
if not p.is_alive():
# A worker that died mid-test still holds its group in the
# scheduler; release it so the group's other tests can run.
shared_queue.finish_previous_test(p.worker_index)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Detect worker failure before taking its scheduler lock

If a worker is killed while inside pop_for_worker or finish_previous_test, the manager-backed Lock remains acquired. This recovery call then blocks the parent indefinitely, before it even checks the worker's nonzero exit code; the global deadline and hung checks also stop running. A focused probe using the actual ParallelTestScheduler reproduced a worker exiting with SIGKILL and finish_previous_test remaining blocked.

Please check unexpected worker exits first and abort/quiesce the run without acquiring worker-owned locks, or move scheduling into a process that survives worker death. Forcibly unlocking and continuing is unsafe because the killed worker may have partially updated the queue and group ownership.

Comment thread tests/clickhouse-test Resolved
@fm4v

fm4v commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110015&sha=c733161a6a81ed345ff294e7136eca3655c3930f&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

04647_use_query_parameter_survives_reconnect.expect (not touched by this PR) failed with return code 1 after 66 s in Stateless tests (amd_debug, parallel); 11 reruns passed. It also failed once on #110665 (2026-09-15, amd_llvm_coverage). The test relies on the server closing an idle connection (idle_connection_timeout=2, then sleep 5) before the next query; under load the client may still hit the in-between window that its own comment describes.

@groeneai

Copy link
Copy Markdown
Collaborator

I'm working on it and will link the fix PR here. What I found so far:

  • Two of the 66 s failures (2026-09-03 and this one, both on this PR's branch) are not the reconnect window. The server closed the idle connection after 2 s as intended, but the client never saw the close: there was no reconnect and no new handshake in the server log, and the SELECT waited until the 60 s timeout. In both runs, 01747_executable_pool_dictionary_implicit_key (no-parallel, which this PR runs in the parallel job) started its executable_pool shell processes while the test's connection was open. Accepted sockets are not close-on-exec (::accept in base/poco/Net/src/SocketImpl.cpp), and ShellCommand runs vfork + execv without closing descriptors, so every child keeps a copy of that connection. I reproduced it locally on master. After the spawn, ss shows the idle connection's server-side socket owned by both sh and clickhouse, and the next query hangs. Without the spawn the client reconnects. This is the odbc-bridge fork/exec socket leak and hung connections #4060 class of server bug, so the main fix goes in the server.
  • The 2026-09-10 failure is the window you describe, but it happened in the setup. The INSERT hit the 2 s idle close (Connection reset by peer), so the table stayed empty and the SELECT returned sum(x) = 0. The setup has to run outside the 2 s session.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is in #125753: accepted sockets are now close-on-exec, so processes the server starts no longer keep a client connection open, and 04647 runs its setup over a separate connection.

Make stateless test execution more parallel-safe through per-run identities, per-test `user_files` sandboxes, `no-parallel` concurrency groups, self-parallel control in `clickhouse-test`, and targeted rewrites of tests that depended on fixed global state. Tests that cannot be isolated keep plain `no-parallel` with a documented `Tag no-parallel:` reason, which the style check now enforces for new tags.

#110015
@@ -39,7 +37,8 @@ WHERE
ORDER BY table;

SELECT '-- Load primary key for all tables';
SYSTEM LOAD PRIMARY KEY;
SYSTEM LOAD PRIMARY KEY test;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve coverage of server-wide primary-key loading

Replacing the table-less SYSTEM LOAD PRIMARY KEY with two table-scoped calls removes the suite's only runtime coverage of the server-wide form. These commands take a different branch of InterpreterSystemQuery::loadOrUnloadPrimaryKeysImpl: they do not exercise its catalog iteration. Removing the load operation from that iteration would now leave every remaining primary-key load test passing, whereas the original memory assertions detected it.

Please retain an isolated table-less load check that first unloads both fixtures and then verifies that the global command restores their primary-key memory. The table-scoped cases can remain parallel.

This branch was successfully deployed

1 active deployment
staging - docs — 31303aa4 Deployed Oct 14, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-testing Test content only (no production code). pr-build Pull request with build/testing/packaging improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants