Skip to content

CI: reduce stateless/integration test setup overhead (baked stateful datasets, DinD image preseed) - #109745

Draft
fm4v wants to merge 18 commits into
masterfrom
nik/ci-bake-stateful-dataset
Draft

fm4v wants to merge 18 commits into
masterfrom
nik/ci-bake-stateful-dataset

Conversation

@fm4v

@fm4v fm4v commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

Related: #109735

Reduces stateless test-job setup overhead (stateful-dataset prep). Combines #109735 into this PR; further work on this topic continues here.

Stateless: bake the stateful datasets into the image. Functional-test env setup attaches hits_v1/visits_v1 from a web disk (read-only, real AWS S3 in us-east-1) and reads them lazily during tests, which is slow enough to make heavy stateful tests time out. A new image clickhouse/clickhouse-stateful-test (a Docker Hub repo name reused from the pre-praktika CI - the robot cannot create new repos) generates a local, self-contained (table_disk, plain_rewritable over local_blob_storage) copy of the datasets at image-build time; clickhouse/stateless-test is built FROM it, so CREATE TABLE attaches the pre-generated store instantly and reads are local. The snapshot parts are cloned byte-for-byte via ATTACH PARTITION ALL FROM (no re-insert, no re-serialization), because many stateful test references depend on the exact on-disk layout of test.hits: part count, physical row order, and per-column sizes. Additionally (from #109735), --no-stateful jobs skip the unused hits/visits preparation entirely; TPC-H/TPC-DS databases are always prepared because their correctness tests are not tagged stateful.

Integration: runtime-overhead experiment. DIND_TMPFS_DATA_ROOT=1 mounts a tmpfs over the nested daemon's data-root (off by default; tmpfs pages count against the job's memory cgroup and the cross-job image cache is bypassed).

An earlier revision of this PR also preseeded the integration DinD image store from a prebuilt clickhouse/clickhouse-integration-test image; that part was removed.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

fm4v added 2 commits July 8, 2026 08:17
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
Functional-test env setup attaches hits_v1/visits_v1 from a `web` disk
(read-only, real AWS S3 in us-east-1) and reads them lazily during tests.
Those lazy per-granule reads are slow enough to make heavy stateful tests
time out. Baking the data into the CI image on a local disk makes both the
attach and the reads fast.

The one disk kind that is both instant-attach (`table_disk=1`, self-contained)
and local-speed is an object-storage disk over a local backend with plain
metadata: `object_storage_type = local_blob_storage`, `metadata_type =
plain_rewritable`. `table_disk` only accepts read-only or plain object-storage
disks (MergeTreeSettings.cpp), which is why `type = local` cannot be used.

New image `clickhouse/stateful-dataset` (registered in praktika) generates the
store at build time: it fetches a static clickhouse binary and, via
`generate.sh`, copies hits_v1/visits_v1 from their web-disk sources
(`create_source.sql`) into a local `plain_rewritable` `table_disk` store under
`/opt/ch-stateful`. `clickhouse/stateless-test` is built FROM this image (single
praktika dependency -> FROM_TAG, so no digest has to be pinned by hand), so it
inherits the baked data.

At serve time `tests/docker_scripts/create.sql` declares the same tables with the
same disk plus `readonly = true`, so `CREATE TABLE` attaches the pre-generated
store instantly; the existing `RENAME datasets.* TO test.*` flow is unchanged
(RENAME works on read-only `table_disk` tables). Custom local disks must live
under `custom_local_disks_base_directory` (`/var/lib/clickhouse/disks/`), so
`prepare_stateful_data` symlinks `/opt/ch-stateful` there instead of relaxing
that guard.

Validated locally (clickhouse-local): generate (plain_rewritable writable) +
serve (readonly CREATE attach), `CREATE ... AS` schema copy, RENAME on a
read-only table_disk table, symlinked disk path, and a second independent attach
of the same store all work and read back correct data.

Scope: hits_v1 + visits_v1 (the web-slow tables). tpch/tpcds are left on their
current disks and can move to the same mechanism as a follow-up. Draft: the
docker image build, build-time generation over the network, image size, and the
end-to-end stateless run are validated by this PR's own CI.
@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [78ebd01]

Summary: ✅


AI Review

Summary

This PR speeds up functional-test setup by baking hits_v1 and visits_v1 into a new base image and by skipping unused dataset prep for --no-stateful jobs. The current patch still regresses several supported test flows and drops one existing web-disk regression check, so it is not ready to merge.

Findings

❌ Blockers

  • [tests/docker_scripts/stress_runner.sh:67-68, tests/docker_scripts/create.sql:152,344] stress_runner.sh still executes create.sql directly, but the new table definitions only work after creating /var/lib/clickhouse/disks/stateful -> /opt/ch-stateful. That symlink is added only in prepare_stateful_data, so the stress job will now fail before the stress run starts.
    Suggested fix: create the same symlink in stress_runner.sh, or move the setup into a shared helper that every create.sql caller uses.
  • [ci/docker/stateful-dataset/generate.sh:18] The dataset image is generated with curl https://clickhouse.com/ | sh, which resolves to a moving external binary and is not part of the Docker digest inputs. Rebuilding the same source later can bake a different plain_rewritable store, so CI now depends on an unreproducible dataset layer whose metadata format can drift from the PR binary.
    Suggested fix: pin an explicit generator binary version, or another repo-controlled generator input, and make it part of the image digest.

⚠️ Majors

  • [ci/jobs/scripts/clickhouse_proc.py:873-879] prepare_stateful_data now hard-wires the dataset attach path to /opt/ch-stateful, but Praktika explicitly supports host-side local runs via --no-docker. In that mode the baked directory is absent, so stateful local runs fail during clickhouse-client < ./tests/docker_scripts/create.sql before any test starts.
    Suggested fix: provision the baked store for host runs as well, or keep a separate non-Docker source path for local stateful runs.
  • [ci/defs/defs.py:121-124, ci/praktika/digest.py:121-139] The new clickhouse/clickhouse-stateful-test image digest is still derived from ./ci/docker/stateful-dataset only, while the runtime schema now also lives in tests/docker_scripts/create.sql. A later PR that edits only create.sql will reuse the stale baked image from master, even though the comments here require the schemas to stay identical.
    Suggested fix: include tests/docker_scripts/create.sql in the image digest/build trigger, or move the shared DDL under ci/docker/stateful-dataset and generate the runtime file from that single source.
  • [tests/docker_scripts/create.sql:152,344, tests/queries/0_stateless/04051_web_disk_stale_connections.sql:4-22] test.hits is no longer backed by a web disk, so 04051_web_disk_stale_connections.sql no longer opens any HTTP connection when it reads test.hits. The test will keep passing even if the stale keep-alive bug returns, which silently drops coverage for the regression this PR was meant to preserve.
    Suggested fix: keep a dedicated web-backed fixture for that test, or leave one hits copy on the old web path for regular stateful jobs.
  • [ci/jobs/functional_tests.py:582-608,777-781] Local targeted runs still decide whether to call prepare_stateful_data by scanning only for the stateful tag, but this PR intentionally keeps tpch and tpcds prep for non-stateful tests. A local run of 04033_tpc_ds_* or 04040_tpc_h_* will therefore skip prep and fail on missing databases.
    Suggested fix: replace the predicate with needs_prepared_env, or at least treat the TPC-H and TPC-DS suites as requiring prep too.
Final Verdict

Changes requested: the new dataset mechanism still breaks supported local and stress flows, and it removes one existing web-disk regression check.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 8, 2026
fm4v added 3 commits July 9, 2026 11:15
…to nik/ci-bake-stateful-dataset

# Conflicts:
#	ci/jobs/scripts/clickhouse_proc.py
…ache image

Every integration job pulls ~30 stable external service images (the ones
pinned inline in tests/integration/compose/*.yml) into the nested DinD
daemon's data-root. Ship them instead as docker-archive tarballs in a new
image, clickhouse/integration-images-cache, and load them at job start, so
the recurring per-job registry pulls become one image layer that is cached
per runner host in the clickhouse_integration_tests_volume data-root.

- ci/docker/integration-images-cache: FROM clickhouse/test-base (praktika
  passes the dependency digest as FROM_TAG), installs skopeo and fetches
  every image from images.txt daemon-less into /preseed (the build runs
  under unprivileged buildkit, so no throwaway dockerd can run there);
  the final stage is FROM scratch so only the archives are shipped. Images
  with no manifest for the build arch are skipped, exactly as
  prefetch-integration-test-images does at job time.
- images.txt is generated by generate_images_list.py from the compose files:
  only inline version-locked references are included; tagless/latest
  references and per-commit clickhouse/* images (runtime-resolved tags) are
  excluded. A new `integration_images_cache` style check fails when the list
  drifts from the compose files; regenerating it changes the directory
  digest, which is what triggers the image rebuild.
- ci/jobs/scripts/seed_dind_images_cache.sh pulls the cache image with the
  nested daemon, streams each archive into `docker load`, drops the cache
  image and leaves a marker image so the next job on the same host skips
  seeding. Fail-open everywhere: on any failure the job just falls back to
  prefetch-integration-test-images, which still runs after seeding.
- The cache image is deliberately NOT chained into
  clickhouse/integration-tests-runner, so local development never downloads
  the multi-GiB preseed layer; seeding is enabled in CI and disabled for
  local runs by default (override with DIND_IMAGES_CACHE=1/0).
Runtime-overhead experiment for integration tests: with
DIND_TMPFS_DATA_ROOT=1, docker_in_docker.sh mounts a tmpfs over
/var/lib/docker before starting the nested daemon, so service-container IO
never touches the host disk. Off by default: tmpfs pages are charged to the
job container's memory cgroup (the job runs with --memory), and the mount
shadows the clickhouse_integration_tests_volume, bypassing the cross-job
image cache. Size is tunable with DIND_TMPFS_SIZE (default 32g).
@fm4v fm4v changed the title CI: bake stateful datasets into a local disk in the stateless-test image CI: reduce stateless/integration test setup overhead (baked stateful datasets, DinD image preseed) Jul 9, 2026
fm4v added 5 commits July 9, 2026 12:40
Docker.build skipped building when `docker manifest inspect` failed with
anything other than "no such manifest". A missing tag in an existing
repository fails that way, but the very first build of a new image (the
repository itself does not exist on Docker Hub yet) fails with
"denied"/"authentication required" instead - and the build was wrongly
skipped as "image exists", breaking every dependent image's FROM:

  failed to resolve source metadata for
  docker.io/clickhouse/stateful-dataset:ee3838c2794996ba2646_amd:
  pull access denied, repository does not exist or may require authorization

as seen on the first Dockers Build run for the new clickhouse/stateful-dataset
and clickhouse/integration-images-cache images in
#109745. Skip only when the
inspect succeeds; rebuilding on a transient inspect failure is idempotent
(the push overwrites the same tag), so failing toward "build" is safe.
The CI robot cannot create new repositories in the clickhouse Docker Hub
org (the Dockers Build push failed with "push access denied, repository
does not exist"), so reuse repositories that have been dead since 2021
(the pre-praktika CI naming scheme) instead of clickhouse/stateful-dataset
and clickhouse/integration-images-cache:

- clickhouse/stateful-dataset -> clickhouse/clickhouse-stateful-test
- clickhouse/integration-images-cache -> clickhouse/clickhouse-integration-test

Directory names, the style-check name and the seeding script are unchanged;
only the image names are. Verified against the Docker Hub API that both
repositories exist, were last pushed on 2021-09-08, carry no praktika-style
digest tags (i.e. are not built by the private repo's CI either), and are
referenced nowhere in this repository.
…l-dataset

# Conflicts:
#	ci/jobs/functional_tests.py
The Dockers Build (amd) job died twice (runner lost, no logs) while building
clickhouse/clickhouse-integration-test on this PR's CI, while the arm job
succeeded and pushed a 6.9 GiB image. The builds run on small style-checker
runners, and the uncompressed docker-archive set is ~15+ GiB plus buildkit's
export copy - consistent with disk exhaustion.

Compress each archive with zstd right after skopeo writes it (peak disk =
compressed total + one uncompressed archive, ~2.5x lower), and ship the
.tar.zst files. `docker load` auto-detects the compression, so the seeding
path is unchanged. Validated locally: image build produces .tar.zst archives
and seed_dind_images_cache.sh loads them successfully.
table_disk = 1,
disk = disk(type = cache, path = 'filesystem_caches/stateful/', max_size = '4G',
disk = disk(type = web, endpoint = 'https://clickhouse-datasets-web.s3.us-east-1.amazonaws.com/store/78e/78ebf6a1-d987-4579-b3ec-00c1a087b1f3/'));
disk = disk(type = object_storage, object_storage_type = local_blob_storage, metadata_type = plain_rewritable, readonly = true, path = '/var/lib/clickhouse/disks/stateful/hits_v1/');

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.

tests/docker_scripts/stress_runner.sh still executes this file directly at tests/docker_scripts/stress_runner.sh:67-68, but that path never creates the /var/lib/clickhouse/disks/stateful -> /opt/ch-stateful symlink that prepare_stateful_data now relies on. After this change the stress job will try to attach datasets.hits_v1 / datasets.visits_v1 from a missing local-disk path and fail before the stress run even starts.

Please create the same symlink in stress_runner.sh, or move the symlink setup into a shared helper that every create.sql caller uses.

Comment thread ci/defs/defs.py
# cannot create new repositories in the clickhouse org, only push to
# existing ones.
name="clickhouse/clickhouse-stateful-test",
path="./ci/docker/stateful-dataset",

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.

clickhouse/clickhouse-stateful-test is still tagged from the contents of ./ci/docker/stateful-dataset (plus Docker dependencies) only, but the runtime attach DDL now also lives in tests/docker_scripts/create.sql. That means a future PR that edits only tests/docker_scripts/create.sql will reuse the old baked image from master, even though this file explicitly says the on-disk schema must stay identical.

Please make the baked image digest/build trigger include tests/docker_scripts/create.sql as well, or move the shared DDL under ci/docker/stateful-dataset and generate the runtime file from that single source of truth.

fm4v added 2 commits July 10, 2026 15:04
The baked store was written by a parallel INSERT (max_insert_threads = 16)
with no final merge, so test.hits ended up with a nondeterministic number
of parts (5 in the amd image, 10 in the arm image) instead of the fully
merged layout of the previous web-disk snapshot. Tests that assert the
part layout of test.hits failed reproducibly in every stateless job:
00098_primary_key_memory_allocated, 00166_explain_estimate,
00183_prewhere_conditions_order, 00167_read_bytes_from_fs.

Insert and OPTIMIZE ... FINAL now happen in a scratch table on the local
disk, and only the merged parts are cloned into the store via
ALTER TABLE ... ATTACH PARTITION ALL FROM: running OPTIMIZE directly on
the store table would leave the merged-away source parts behind in the
baked image, because outdated parts are not removed from disk on shutdown.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109745&sha=afb1f65223e73712c3b7886c00d0269956087b49
PR: #109745
Remove the clickhouse/clickhouse-integration-test preseed image
(ci/docker/integration-images-cache), the seeding hook in the integration
test job, the seed script, and the images-list drift guard in the style
check. The opt-in DIND_TMPFS_DATA_ROOT experiment in docker_in_docker.sh
stays (it is independent of the preseed).
# The image has no clickhouse binary; fetch a static one just to run this one-off
# generation. The on-disk MergeTree format is backward compatible, so the server
# under test (built from the PR) reads what a recent stable produced here.
curl -fsSL https://clickhouse.com/ | sh

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.

curl -fsSL https://clickhouse.com/ | sh is not pinned here; in a probe against this PR it resolved to the moving builds.clickhouse.com/master/<arch>/clickhouse binary, not a fixed release. That external version is also not part of the clickhouse/clickhouse-stateful-test digest inputs, so a later rebuild of the same logical image can write a different baked table_disk store from the same repo state.

Because this image is consumed as a shared CI base, that makes the datasets non-reproducible and risks format drift between the external generator binary and the PR binary that later attaches /opt/ch-stateful. Please pin an explicit ClickHouse binary version, or another repo-controlled generator input, instead of the website default.

…baked store

Re-inserting the data changed the on-disk layout that stateful test
references were built against, in ways OPTIMIZE ... FINAL cannot restore:
the physical row order within equal sort keys differs per merge
interleaving (00161_parallel_parsing_with_names does LIMIT without
ORDER BY and got a different checksum on arm than on amd), and a current
stable server serializes columns differently than the snapshot (e.g.
sparse serialization for the mostly-empty SearchPhrase), which flips the
size-based prewhere condition reorder asserted by
00183_prewhere_conditions_order.

Instead of INSERT + OPTIMIZE, clone the snapshot parts with
ALTER TABLE ... ATTACH PARTITION ALL FROM datasets.*: part directories
are copied byte-for-byte with no re-serialization, so the baked store is
exactly the web-disk snapshot every reference was produced against.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109745&sha=2d8b8c0c4d39928c26de9e544115a09a87c254b2
PR: #109745
table_disk = 1,
disk = disk(type = cache, path = 'filesystem_caches/stateful/', max_size = '4G',
disk = disk(type = web, endpoint = 'https://clickhouse-datasets-web.s3.us-east-1.amazonaws.com/store/78e/78ebf6a1-d987-4579-b3ec-00c1a087b1f3/'));
disk = disk(type = object_storage, object_storage_type = local_blob_storage, metadata_type = plain_rewritable, readonly = true, path = '/var/lib/clickhouse/disks/stateful/hits_v1/');

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.

04051_web_disk_stale_connections.sql is still a reproducer for stale HTTP keep-alive reuse on a web disk, and it reads test.hits directly at tests/queries/0_stateless/04051_web_disk_stale_connections.sql:4-22. After this change test.hits comes from local_blob_storage, so the query never opens a web-disk HTTP connection anymore. The test will keep passing even if the stale-connection bug comes back. We need either a dedicated web-backed fixture for that test or to leave one hits copy on the original web path in regular stateful jobs.

test.hits now lives on an object-storage-typed disk backed by local files
(the baked stateful dataset store), which takes the remote read path:
reads are split into merge_tree_min_bytes_per_task_for_remote_reading
tasks (2 MB by default) and each task over-reads at its boundary, adding
~25-30% to ReadBufferFromFileDescriptorReadBytes - measured locally as
2.59 GiB of filesystem reads for 2.02 GiB of compressed data, and for the
1.2 GB test.hits just over the 1.5 GB bound asserted by the test. With a
256 MiB task size the overhead is ~1% and the measurement again reflects
the compressed data actually read, keeping the original intent of the
test (it guards against a bug that read 3 GB instead of 1.2 GB).

The root cause - DiskObjectStorage::isRemote() returns true even when
the underlying object storage is LocalObjectStorage, so physically local
blob stores use remote read planning - is out of scope here.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109745&sha=eb618417b28e33bc0da573239d4ffab937f31763
PR: #109745
if not CH.prepare_stateful_data(
with_s3_storage=is_s3_storage,
is_db_replicated=is_database_replicated,
no_stateful=is_no_stateful,

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 invariant here is that some non-stateful suites still need environment prep (04033_tpc_ds_*, 04040_tpc_h_*), but the local-run shortcut above still keys only on the presence of the stateful tag (functional_tests.py:582-608). A local run that targets only one of those TPC tests sets has_stateful_tests = False, so this block never calls prepare_stateful_data and the run fails on missing tpch / tpcds.

Please teach the local predicate to represent needs_prepared_env rather than has_stateful_tests, or at least special-case the TPC-H / TPC-DS suites here as requiring prep too.

fm4v added 4 commits July 10, 2026 22:25
The previous commit put the new setting into the query's SETTINGS clause
and SQL comments directly above the query. Both break the test's
query_log lookup, which matches the exact query text: clickhouse-client
attaches leading comments to the statement it sends, so the logged query
no longer equals the match string, and the assertion SELECT returned no
rows at all (flaky check failed on every rerun). Set the session setting
with SET and keep the measured query text byte-identical to what it was
before.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109745&sha=5b1eec7d2919a4ac0ae5544575f4780de5aba1ef
PR: #109745
…l-dataset

# Conflicts:
#	ci/jobs/functional_tests.py
#	ci/jobs/scripts/clickhouse_proc.py
…ked store

Raising merge_tree_min_bytes_per_task_for_remote_reading did not help:
measured on the real baked hits store, the scan reads ~1.86 GB from the
filesystem for ~1.27 GB of compressed data regardless of task size, and
even with max_threads = 1 - the over-read is not from task boundaries.
The remote read path re-reads the compressed block containing a mark on
each seek instead of reusing the current buffer like the local read path
does (per-column factors measured 1.05x-1.5x depending on block/granule
geometry). No settings combination removes it robustly (the best one
left a 4% margin under the old 1.5 GB threshold).

Drop the ineffective SET, keep the query identical to master, and raise
the threshold to 2.5 GB, which still catches the historical bug this
test guards against (reading ~2.5x the compressed size would now produce
~4.6 GB).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109745&sha=8b1c1d147438eb3af5f4dcaba61047ea3ec367ec
PR: #109745
The absolute byte threshold can not be made stable: the filesystem
over-read of the object-storage-typed baked dataset store is
timing-dependent (measured 1.45x-1.77x of the table size across local
release runs, 1.57x-1.65x on the amd_debug CI binary locally, and over
1.97x on a shared CI runner), so any fixed number either flakes or stops
guarding.

Rewrite the assertions as ratios against sum(bytes_on_disk) of test.hits
from system.parts:
- ReadCompressedBytes < 1.3x - the tight, storage- and build-independent
  guard for the original bug (reading additional compressed data);
  measured 1.010-1.017 across all runs on both release and debug.
- ReadBufferFromFileDescriptorReadBytes < 4x - a loose gross-thrash
  guard, sized at double the worst environmental over-read observed.

Also match the query_log row by log_comment instead of the exact query
text, which breaks whenever the query or the comments above it change
(clickhouse-client attaches leading comments to the statement).

Validated by running the test SQL verbatim against the real baked hits
store (byte-identical clone of the web snapshot) in a query_log-enabled
clickhouse local, with both the release binary and this PR's amd_debug
CI binary.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109745&sha=6239bf1b69a7ab6dc8938f83ee3e7b37410a48e7
PR: #109745
# sit under custom_local_disks_base_directory (/var/lib/clickhouse/disks/), so
# expose the baked store there via a symlink instead of relaxing that guard.
mkdir -p /var/lib/clickhouse/disks
ln -sfn /opt/ch-stateful /var/lib/clickhouse/disks/stateful

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.

prepare_stateful_data is also used in supported Praktika host runs: ci/praktika/__main__.py advertises --no-docker, and ci/praktika/runner.py skips the container entirely in that mode. After this change we always symlink /var/lib/clickhouse/disks/stateful to /opt/ch-stateful, but that baked dataset tree exists only inside clickhouse/stateless-test.

On a host-side local run the symlink therefore dangles, and clickhouse-client < ./tests/docker_scripts/create.sql fails before any stateful test starts. Please keep a non-Docker path for local runs as well, for example by provisioning the baked store on the host or by preserving the previous source-table setup for --no-docker / direct-script runs.

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]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Dear @fm4v, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant