Skip to content

CI: skip unused stateful dataset prep for --no-stateful jobs - #109735

Closed
fm4v wants to merge 1 commit into
masterfrom
nik/ci-visible-stateful-prep
Closed

fm4v wants to merge 1 commit into
masterfrom
nik/ci-visible-stateful-prep

Conversation

@fm4v

@fm4v fm4v commented Jul 8, 2026

Copy link
Copy Markdown
Member

Description / motivation

Functional-test env setup shows a multi-minute blank gap in job.log right after Restarting clickminio (timeout 60s), which reads like a hung minio restart:

[2026-06-01 18:34:43] Restarting clickminio (timeout 60s)
[2026-06-01 18:43:48] Run command: [clickhouse-client --query "insert into system.zookeeper ...]

It is not the restart. The clean mc admin service restart --wait succeeds within its bound (there are no fallback/warning lines anywhere in the log). The ~9 minutes is prepare_stateful_data loading the hits/visits datasets — lazily reading datasets.hits_v1/visits_v1 from the web disk (real AWS S3, us-east-1) and writing test.hits/test.hits_s3 into the local minio (the writes are local, not real S3). The step's output goes to a log file and stdout is block-buffered under Result.from_commands_run's Tee, so nothing flushes for minutes and the gap looks like a stuck restart.

prepare_stateful_data runs on every functional-test job (has_stateful_tests is always True in CI). But a --no-stateful job (the s3 storage and DatabaseReplicated variants) filters out every stateful-tagged test, and those are the only consumers of test.hits / test.visits / test.hits_s3 / test.hits_parquet / datasets (verified: 0 non-stateful consumers across tests/queries/0_stateless). The TPC-H / TPC-DS correctness tests (04033_tpc_ds_*, 04040_tpc_h_*) are not tagged stateful, so they still run and their tpch/tpcds databases must stay.

This PR:

  • Gates the hits/visits/datasets section of the prep script behind a NO_STATEFUL guard and always creates tpch/tpcds. functional_tests.py derives the flag from the runner options (--no-stateful in runner_options), not a specific storage option, so any --no-stateful job benefits.
  • Makes the step attributable: a flushed start/end banner with elapsed time, so the load no longer masquerades as a stuck clickminio restart in job.log.

Behavior is unchanged for regular parallel/sequential stateless jobs (they run stateful tests, so they still prepare everything). Verified the generated script with bash -n and a stubbed-client run in both modes: NO_STATEFUL=1 creates only test + tpcds + tpch; the default path is unchanged.

Follow-up (not in this PR): bake hits_v1/visits_v1 into the stateless-test image as a local plain object-storage disk (object_storage_type=local_blob_storage, metadata_type=plain_rewritable, table_disk=1) so reads are local-speed instead of lazy web-disk reads. That needs an offline-generated, hosted dataset image + build validation of the disk DDL, so it is tracked separately.

CI report (source of the log):
https://s3.amazonaws.com/clickhouse-test-reports/PRs/106250/4364e2f746b647512274e6e0185b788c6066e8dc/stateless_tests_amd_tsan_s3_storage_parallel_1_2/job.log

Related: #106250

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)

Functional-test env setup shows a multi-minute blank gap in job.log right
after "Restarting clickminio (timeout 60s)", which reads like a hung minio
restart. It is not: the clean `mc admin service restart --wait` succeeds
within its bound (no fallback/warning lines in the log), and the time is
`prepare_stateful_data` loading the hits/visits datasets - lazily reading
`datasets.hits_v1`/`visits_v1` from the web disk (real AWS S3, us-east-1)
and writing `test.hits`/`test.hits_s3` into the local minio. Its output
goes to a log file and stdout is block-buffered under
`Result.from_commands_run`'s `Tee`, so nothing flushes for minutes.

`prepare_stateful_data` runs on every functional-test job (`has_stateful_tests`
is always True in CI). But a `--no-stateful` job (the `s3 storage` and
`DatabaseReplicated` variants) filters out every `stateful`-tagged test, and
those are the *only* consumers of `test.hits`/`test.visits`/`test.hits_s3`/
`test.hits_parquet`/`datasets` (verified: 0 non-stateful consumers across
`tests/queries/0_stateless`). The TPC-H/TPC-DS correctness tests
(`04033_tpc_ds_*`, `04040_tpc_h_*`) are NOT tagged `stateful`, so they still
run and their databases must stay.

So gate the hits/visits/datasets section of the prep script behind a
`NO_STATEFUL` guard and always create `tpch`/`tpcds`. `functional_tests.py`
derives the flag from the runner options (`--no-stateful in runner_options`),
not from a specific storage option, so any `--no-stateful` job benefits.

Also make the step attributable: print a flushed start/end banner with elapsed
time so the load stops masquerading as a stuck clickminio restart in job.log.

Log with the gap:
https://s3.amazonaws.com/clickhouse-test-reports/PRs/106250/4364e2f746b647512274e6e0185b788c6066e8dc/stateless_tests_amd_tsan_s3_storage_parallel_1_2/job.log
Related: #106250
@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6658cc7]

Summary: ✅


AI Review

Summary

This PR skips the unused hits / visits preload for --no-stateful functional-test jobs and adds explicit start/end logging around prepare_stateful_data. The CI-path change looks sound, but the new tpch / tpcds contract is not carried through the local targeted-run shortcut, so local functional_tests.py --test 04033_tpc_ds_* / 04040_tpc_h_* runs can still fail because setup is skipped entirely.

Findings

⚠️ Majors

  • [ci/jobs/functional_tests.py:328] --no-stateful no longer means "no prepared data needed": the untagged 04033_tpc_ds_* / 04040_tpc_h_* tests still require tpch / tpcds. The local-run has_stateful_tests heuristic at functional_tests.py:510-536 only looks for the word stateful, so these tests suppress prepare_stateful_data and fail with missing databases when run locally via --test.
    Suggested fix: make the local shortcut compute whether the selected tests need prepared data, and keep prep enabled for tpch / tpcds consumers as well.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: update the local --test path so targeted 04033_tpc_ds_* / 04040_tpc_h_* runs still execute prepare_stateful_data (or equivalent tpch / tpcds setup).

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 8, 2026
# visits_v1 from the web disk, real AWS S3), so signal prepare_stateful_data
# to skip it. Keyed off the actual runner flag, not a specific storage
# option, so any --no-stateful job wins.
is_no_stateful = "--no-stateful" in runner_options

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.

The new NO_STATEFUL path fixes the CI jobs, but it does not carry the same contract through the local --test shortcut. In local runs we still set has_stateful_tests = False unless a selected file contains the word stateful ([functional_tests.py:510-536]), and every 04033_tpc_ds_* / 04040_tpc_h_* test intentionally lacks that tag. So prepare_stateful_data is skipped entirely for a local run like python3 ci/jobs/functional_tests.py --options 's3 storage' --test 04033_tpc_ds_q01 ..., and neither tpcds nor tpch gets created even though this PR now treats them as required in --no-stateful mode. Please teach the local heuristic to preserve prep for those consumers as well, or replace it with a more explicit needs_prepared_data check.

@fm4v

fm4v commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

Combined into #109745 (its commits are merged into that branch); closing in favor of the combined PR.

@fm4v fm4v closed this Jul 9, 2026
Bartok9 pushed a commit to Bartok9/ClickHouse that referenced this pull request Oct 9, 2026
… --no-stateful

The `s3 storage` stateless jobs pass `--no-stateful`, so `clickhouse-test`
skips every `stateful`-tagged test, the only readers of `datasets.*`,
`test.hits`, `test.visits`, `test.hits_s3` and `test.hits_parquet`. Their
preparation still copied the datasets into S3-backed tables twice, which took
367-763 s per `amd_tsan, s3 storage, parallel` shard and 460-748 s per
`amd_llvm_coverage, *, s3 storage` job on master.

`prepare_stateful_data` now gets the runner's `--no-stateful` decision and
skips those tables when it is set. `tpch`/`tpcds` are still loaded because the
TPC-H/TPC-DS tests are not tagged `stateful`. The flag is taken from the
runner options rather than from `s3 storage`, so a job that runs stateful tests
always gets its data. Jobs without `--no-stateful` run the same statements; the
three `datasets` statements just move after the independent TPC loaders.

The same guard was proposed in ClickHouse#109735 / ClickHouse#109745 by @ fm4v.

Requested in ClickHouse#119542 (comment)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant