Skip to content

Export system logs to the CI Logs cluster from integration tests - #116031

Open
alexey-milovidov wants to merge 68 commits into
masterfrom
integration-tests-logs-export
Open

alexey-milovidov wants to merge 68 commits into
masterfrom
integration-tests-logs-export

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

The CI Logs export previously worked only in functional tests, stress tests and fuzzers. This PR makes it work in integration tests: every ClickHouse server started by an integration test now exports its system log tables (system.query_log, system.text_log, ...) to the CI Logs cluster, so CI failures can be investigated with full structured logs instead of only the artifact tarballs.

Since each integration test spins up one or more servers, the exported tables gain two new columns: test_name (the test module: the suite directory for a single-file suite, e.g. test_storage_s3, and <suite>/<module> for a multi-file suite, e.g. test_prometheus_protocols/test_series_api) and node_name (the instance name within the cluster, e.g. node1). Functional tests, stress tests and fuzzers fill them with empty strings. test_name is also added to the destination tables' ORDER BY (after check_name) and gets a set(100) skip index.

How it works (the new helper tests/integration/helpers/ci_logs_export.py, the integration-tests counterpart of setup_log_cluster.sh):

  • After a cluster starts, each eligible instance gets a Distributed system.<table>_sender table and a system.<table>_watcher materialized view per system.*_log table, forwarding every flushed log block to a structure-hash-named destination table on the CI Logs cluster. The structure hashes are byte-identical to the ones setup_log_cluster.sh computes, so functional and integration tests share the destination tables.

  • The _watcher views are created with DEFINER = ci_logs_sender and tests/config/users.d/ci_logs_sender.yaml - the very config the functional tests, clickbench, sqlstorm and the fuzzers install - is copied into the instance users.d, so the export runs with its own pinned settings (short send/receive timeouts, async inserts, no cache pollution, max_memory_usage_for_user = 0), held in place by the profile's readonly constraints, instead of the settings of the default profile the test configured for the instance. Reusing the file rather than copying its contents keeps the two export paths from drifting.

  • Because that user and its profile are visible in system.users/system.settings_profiles, the tests that assert the complete access-control state of an instance (test_grant_and_revoke::test_introspection, test_settings_profile::test_show_profiles, test_disabled_access_control_improvements/test_row_policy) filter the export's entities out with the new helpers.ci_logs_export.without_sender_user. The row policy suite needs it because with the access control improvements disabled UsersConfigParser::parseRowPolicies generates a permissive policy for every user of the users config, so ci_logs_sender adds one per table. The remaining access-control suites compare contiguous SHOW ACCESS blocks of row policies or quotas, which the added entries do not split.

  • Only instances running the binary under test export logs: the base clickhouse/integration-test image and the images derived from it (currently clickhouse/integration-test-with-unity-catalog, used by test_database_delta), each at the tag built for the current commit, plus every with_installed_binary instance whatever its image is - the binary under test is mounted into those containers as /usr/share/clickhouse_fresh and restart_with_latest_version swaps the server to it. That is eligibility of the container (ci_logs_export_supported); whether the export is on right now is ci_logs_export_enabled, which starts false for a with_installed_binary instance: restart_with_latest_version installs the configs before the fresh binary starts and sets the export up once the server is up, and restart_with_original_version flushes, drops the _sender/_watcher tables and removes the configs first. So the upgraded phase of test_statistics_minmax_upgrade, test_version_update and the rest is exported, while the old-release phases stay out. The CLICKHOUSE_CI_LOGS_* variables are passed to every supported container at creation, because the config written at the swap resolves them with from_env and a server that cannot resolve one refuses to start. ci/tests/test_ci_logs_export_images.py derives the expected image set from the FROM lines of the Dockerfiles under ci/docker/integration and fails if a new derived image is missing from the map or if its tag environment variable diverges from IMAGES_ENV, and guards the upgrade path itself.

  • The remote destination tables are created once per job: the result is cached in marker files shared between tests and pytest-xdist workers. If the CI Logs cluster is unreachable, the export is disabled for the rest of the job after a single probe.

  • Per-server cost. Every instance.query starts its own clickhouse-client process, which costs about half a second whatever the statement does, so the setup is two round trips per server: SYSTEM FLUSH LOGS plus the structure query, then all the CREATE statements at once, ending with a query for the _watcher views that actually exist (a partial failure must not leave the shutdown flush referencing a _sender table that was never created). Creating each table with its own call instead cost ~11 s per server, which was most of an integration test job's wall clock: on the run of 70f1e429 all six Integration tests (amd_asan_ubsan, db disk, old analyzer) shards took ~7350-7420 s against ~6240 s on master, and five of them were killed by the 7200 s pytest session timeout.

  • The state the export adds to an instance is visible in system.tables, system.clusters and system.distribution_queue, so the tests that assert the complete contents of one of those - test_system_logs_recreate, test_cluster_discovery/test_dynamic_clusters, test_replicated_database_system_clusters_log_level, test_mask_sensitive_info::test_query_masking_rule_with_ddl - now assert the property they are about rather than the whole table.

  • On cluster shutdown, the logs and the pending Distributed sends are flushed, so the tail of the logs is not lost with the containers. The export is best effort and never fails the tests themselves.

  • The ci_logs_sender user is declared with a random password_sha256_hex rather than no_password: a server started with allow_no_password: 0 refuses to parse a users config that declares such a user (Authentication type NO_PASSWORD is not allowed, e.g. test_no_password_existing_user). Nobody authenticates as it - it only exists as the DEFINER of the _watcher views.

  • The parallel phase of an integration job gets +900 s of session timeout when the export is enabled: the setup and the shutdown SYSTEM FLUSH LOGS per server put the shards at 6.9-7.4 ks against a master p50 of 6.2 ks, so two of them were cut short by the 7200 s budget rather than by a test.

Credential safety (the instance directories, compose files and pytest logs are collected as CI artifacts):

  • The instance config references the credentials with from_env and hide_in_preprocessed="1" (verified that preprocessed_configs omits them), docker compose passes them into the containers from its process environment (only variable names appear in the compose file), and the remote DDL client receives the password via the CLICKHOUSE_PASSWORD environment variable instead of the command line. The environment dump in cluster.py now masks variables matching PASSWORD|SECRET|TOKEN|ACCESS_KEY.
  • The Distributed async-send directory names use the default compact format (shard1_replica1), so no credentials appear under the instance database/ directory either.

Tested locally end-to-end: a real ci.praktika integration run of test_accept_invalid_certificate (2 nodes) against a local stand-in for the CI Logs cluster — all 6 tests passed, 17 log tables per node were exported with correct test_name/node_name, the destination table names matched the hashes computed by the setup_log_cluster.sh method exactly, and no credential values appeared anywhere under _instances*/.

The ci_logs_sender part was verified the same way: the YAML in users.d defines the user and the profile, every _watcher view gets definer = 'ci_logs_sender', rows arrive in the destination tables for both nodes, and inside such a view the profile wins over the settings of the query that triggers it (max_memory_usage_for_user 0 instead of 5000000000, async_insert 1 instead of 0, send_timeout 15 instead of 300, distributed_foreground_insert 0 instead of 1, enable_filesystem_cache_on_write_operations 0 instead of 1). test_grant_and_revoke::test_introspection passes with the export enabled.

Changelog category (leave one):

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

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

The CI Logs export previously worked only in functional tests, stress
tests and fuzzers. Now every ClickHouse server started by an integration
test exports its system log tables (system.query_log, system.text_log,
...) to the CI Logs cluster as well, via the new helper
tests/integration/helpers/ci_logs_export.py: after the cluster starts,
each eligible instance gets a Distributed `<table>_sender` table and a
`<table>_watcher` materialized view per log table, forwarding the data
to a structure-hash-named destination table (the same mechanism as
`setup_log_cluster.sh` uses for functional tests, with byte-identical
structure hashes, so the destination tables are shared).

The exported tables gain two new columns: `test_name` (the integration
test module, e.g. `test_storage_s3`) and `node_name` (the instance name
within the cluster, e.g. `node1`). Functional tests, stress tests and
fuzzers fill them with empty strings. `test_name` is also added to the
destination tables' `ORDER BY` and gets a skip index.

Details:
- The credentials are never materialized in files that are collected as
  CI artifacts: the instance config references them with `from_env`
  (plus `hide_in_preprocessed`), docker compose passes them into the
  containers from its process environment, and the remote DDL client
  receives the password via the `CLICKHOUSE_PASSWORD` environment
  variable. The environment dump in `cluster.py` now masks secrets.
- The remote destination tables are created once per job (a marker-file
  cache shared between tests and pytest-xdist workers); if the CI Logs
  cluster is unreachable, the export is disabled for the rest of the job
  after a single probe.
- Only instances running the binary under test export logs (old release
  images and `with_installed_binary` instances are excluded).
- On cluster shutdown the logs and the pending Distributed sends are
  flushed, so the tail of the logs is not lost with the containers.
- The export is best effort and never fails the tests themselves.
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7a8273a]

Summary: ✅


AI Review

Summary

The PR exports integration-test system logs to CI Logs with per-suite and per-node metadata, isolates export settings and credentials, and handles restart and shutdown recovery. Reviewed the full diff and current code at 7a8273ab5c3293ef016599088c8f79bae6b394d8, including every reply in all 35 prior review threads. No actionable findings remain. All 34 focused tests in ci/tests/test_ci_logs_export_images.py passed locally, including the latest exporter-object naming regression check.

Missing context / blind spots
  • ⚠️ Full integration CI and private sync for the reviewed head are still pending. Docker integration tests and private-only adaptations were not independently rerun during this review; their CI results will complete runtime validation.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 24, 2026
Two behaviors of `setup_log_cluster.sh` were missing from the Python
port:
- export only tables with a `MergeTree` engine, to exclude virtual
  system tables that merely match the `%_log` name pattern (e.g.
  `system.user_query_log` with the `SystemUserQueryLog` engine);
- strip per-column comments from the destination `CREATE` statement:
  wide tables like `system.metric_log` (~1800 columns, each with a long
  description) expand into a statement larger than the default
  `max_query_size`, and the comments are not needed on the aggregation
  tables anyway.

Also raise `max_query_size`: `formatQuery` has to parse the original
statement, including the comments, before they are stripped. The
integration base config removes `metric_log`, but tests can re-enable
it through custom configs.
Comment thread tests/integration/helpers/cluster.py Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7a8273ab5 with master b6ed65a67 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 4cbc68b27; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline.

Job report

…he CI Logs probe, allow YAML main configs

- `test_name` is now derived from `cluster.base_path`, so every module of a
  multi-file suite is identified separately (`test.py` still falls back to the
  suite directory name).
- The marker cache is namespaced by the identity of the CI job, so a transient
  outage cannot disable the export in later runs on the same worker.
- The connectivity probe retries transient `Connection reset by peer` and
  `MEMORY_LIMIT_EXCEEDED` errors, mirroring `check_logs_credentials` in
  `setup_log_cluster.sh`, before writing the job-wide `disabled` marker.
- Dropped the `main_config_name == "config.xml"` restriction: instances with a
  YAML main config merge the XML `config.d` fragments just as well.
Comment thread tests/integration/helpers/cluster.py Resolved
…r`, widen the eligibility check

The `_watcher` materialized views are now created with
`DEFINER = ci_logs_sender`, and the instances get a `zzz_ci_logs_sender.xml`
users config with that user and its pinned profile - the XML counterpart of
`tests/config/users.d/ci_logs_sender.yaml` used by functional tests. Without
it the export inherited the settings of whatever query triggered the log
flush, which reintroduces the long `send_timeout` (slow shutdown) and the
cache/memory settings leakage that the dedicated profile exists to prevent.

The eligibility check hard-coded `clickhouse/integration-test` with
`DOCKER_BASE_TAG`, which silently excluded suites running a derived
current-binary image, such as `test_database_delta` with
`clickhouse/integration-test-with-unity-catalog` (that image is
`FROM clickhouse/integration-test`). It now gates on the image being one of
the current-binary integration test images at its own tag.
…map, fix the introspection tests

Three fixes on top of the previous commit.

1. The `ci_logs_sender` profile and user were copied into `ci_logs_export.py` as
XML. The values and, more importantly, their readonly constraints then have to be
kept in sync by hand with `tests/config/users.d/ci_logs_sender.yaml`, which the
functional tests, `clickbench`, `sqlstorm` and the fuzzers install, and nothing
fails when they drift - the export would just silently start running with
different settings than the functional one. The instance config is now that same
file, copied into `users.d` (ClickHouse loads `.yaml` from a `.d` directory), so
there is one definition for both export paths.

2. `CURRENT_BINARY_IMAGE_TAG_ENV` had no guard, which is the rot the review asked
about: a new image derived from `clickhouse/integration-test` would silently stop
exporting logs. `ci/tests/test_ci_logs_export_images.py` now derives the expected
set of images from the `FROM` lines of the Dockerfiles under
`ci/docker/integration` and fails if the map misses one or if a tag variable
diverges from `IMAGES_ENV` (the previous comment referred to a
`IMAGE_TAG_ENV_VARIABLE` that does not exist). The map moved to
`ci_logs_export.py` so that the test can import it without `helpers.cluster`,
which needs `docker`, `kazoo` and `minio`. The map deliberately stays an explicit
list rather than a prefix match on `clickhouse/integration-test`:
`clickhouse/integration-test-with-hms` starts `FROM eclipse-temurin:8-jre` and
carries no ClickHouse binary.

3. Installing a config-defined user makes it visible in `system.users` and
`system.settings_profiles`, which breaks the tests that assert the *complete*
access-control state of an instance. Verified against a server with the config
installed: `SHOW USERS`, `SHOW CREATE USERS`, `SHOW GRANTS FOR ALL` (three lines
for that user) and the `CREATE USER` block of `SHOW ACCESS` all gain entries, so
`test_grant_and_revoke::test_introspection` and
`test_settings_profile::test_show_profiles` would have gone red in CI only, where
the export is enabled. They now filter the export's entities out with the new
`helpers.ci_logs_export.without_sender_user`. The other suites that inspect
access control compare contiguous `SHOW ACCESS` blocks of row policies or quotas,
which the added user and profile do not split - `ci_logs_sender` sorts before
`default` inside its own entity-type group.

`test_introspection` passes with the export enabled against a local stand-in for
the CI Logs cluster, as does a full `test_accept_invalid_certificate` run (6/6,
both nodes exporting with `definer = 'ci_logs_sender'`).
…cache per-run and `connected` authoritative

- Every `EXTRA_COLUMNS_EXPRESSION` producer now emits the columns in exactly the
  `EXTRA_COLUMNS` order. The local `*_sender` table is created as
  `SELECT {expression}, *`, so a different order gave it a header different from
  the destination table, and `Distributed` converted every exported batch by
  name, logging a structure-mismatch warning for each of them - which
  `system.text_log` then exported as well. The integration-test job provides the
  expression in two parts (`EXTRA_COLUMNS_EXPRESSION_HEAD` /
  `EXTRA_COLUMNS_EXPRESSION_TAIL`), and the helper inserts the per-server
  `test_name` and `node_name` between them.
- A local run (no `--run-id`, no check name) namespaces the marker cache by the
  checkout and by the id of the pytest session, so a transient outage in one run
  no longer suppresses the export in every later run on the same machine.
- A successful probe is authoritative: a `pytest-xdist` worker that fails to
  connect after another worker has already created the `connected` marker no
  longer disables the export for the rest of the job.
- `ci/tests/test_ci_logs_export_images.py` guards the column order of every
  producer, the shared structure with `setup_log_cluster.sh`, and both cache
  behaviours.
…ogs-export

`master` moved the log-export setup of the single-server jobs into
`ci/jobs/scripts/log_export.py`, so the extra-columns expression is now built
there for every job: `extra_columns_expression_head` / `_tail` give the
integration tests the two parts they insert `test_name` and `node_name`
between, and `extra_columns_expression` composes the whole expression, in the
`EXTRA_COLUMNS` order, for the jobs that export the logs of one server.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure of 04327_backup_s3_base_credentials_metadata in Stateless tests (amd_debug, parallel) and provide a fix in a separate PR. If a fix is already in progress, link it here.

It is unrelated to this PR (which only touches the CI logs export and the integration-test helpers): the test also fails on master (81 occurrences on 2026-08-25 and one on 2026-08-29 in the CI database), and the harness reran it 7 times with the same randomized settings without reproducing it. The reason is Code: 598. DB::Exception: A concurrent backup from BackupsWorker, so the test appears to race with a concurrently running backup of another test rather than to depend on the randomized settings.

@groeneai

Copy link
Copy Markdown
Collaborator

Root cause is in BackupImpl::createLockFile, not a race with another test's backup.

The destination path is scoped to $CLICKHOUSE_DATABASE, so no sibling test could write to it. clickhouse-server.log, query ad933fe9-344d-424a-964d-735a0466d61e:

02:39:36.198555 WriteBufferFromS3: Create WriteBufferFromS3 ... key backups/test_u5c0e1c6l4r5/base_credentials_metadata_inc_6/.lock
02:39:39.254138 S3ClientRetryStrategy: Attempt 1/1001 failed with retryable error: ..., Poco::Exception. Code: 1000, e.code() = 0, Timeout
02:39:39.280447 AWSClient: Retrying S3 request to: .../.lock, aws sdk attempt: 2, clickhouse attempt: 1, kind: Write
02:39:39.381402 AWSClient: Response status: 412, Precondition Failed
02:39:39.381612 WriteBufferFromS3: S3Exception name PreconditionFailed ... key .../.lock, object size 36
02:39:39.384411 BackupImpl: Checking lock file .lock
02:39:39.386992 deleteFileFromS3: Object with path .../.lock was removed from S3
02:39:39.403031 BackupsWorker: Failed to make backup ...: Code: 598 ... A concurrent backup ... detected

The conditional PutObject of .lock timed out on the client after about 3 s but had been applied; the retry failed If-None-Match with 412; the catch in createLockFile read the lock back, found this attempt's own 36-byte UUID, and threw at BackupImpl.cpp:968, the lock_contents_match branch. The unwind then removed that lock, which removeLockFile only does once checkLockFile confirms the contents match this attempt, so the object sitting in the destination was this backup's own lock and not another backup's. No randomized setting is involved, which is why the 7 reruns passed.

That is the defect #116376 fixes, and it removes exactly this throw. I am not opening a separate PR: it would duplicate yours. The rest of the report is downstream of this one exception (BACKUP_NOT_FOUND for inc_6, the 404s reading inc_6/.backup).

One correction on the CI database counts. Scoping true master as head_ref = 'master' AND pull_request_number = 0, this test has 0 master failures in 30 days. The 81 rows on 2026-08-25 are all from PR 116223, which edits both 04327_backup_s3_base_credentials_metadata.sh and its .reference, and the row on 2026-08-29 is this PR's own run above. The only true-master occurrence of this signature in 90 days is 02803_backup_tmp_files on Stateless tests (arm_binary, parallel) at 2026-08-25 03:31:49, sha 20743c1a, which is the report #116376 already cites.

…er` tables on shutdown

The `_watcher` views insert as `ci_logs_sender`, whose profile has `async_insert = 1`
and `wait_for_async_insert = 0`, so the rows `SYSTEM FLUSH LOGS` materialises could still
be in the asynchronous insert queue when `SYSTEM FLUSH DISTRIBUTED` ran, and were lost with
the container. `flush_before_shutdown` now runs `SYSTEM FLUSH ASYNC INSERT QUEUE` in
between, the order `stop` in `ci/jobs/scripts/log_export.py` already uses; the sequence is
built by `_shutdown_statements` and covered by two guard tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: Stress test (arm_debug) - Logical error: Not-ready Set is passed as the second argument for function 'in' (STID 0250-4e52, the stack of the closed #115010, still tracked in #107619) - and provide a fix in a separate PR. If the fix is already in progress, link it here. This PR only touches Python in tests/integration/helpers and ci/, and the two red integration shards (5/6, 6/6) are Container memory budget exceeded (/docker) infrastructure failures.

Comment thread tests/integration/helpers/cluster.py Resolved
@groeneai

groeneai commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Route pinned from this job's own artifacts. The fix is already open: #114058 (mine, since 2026-08-09), so no separate PR from me for this one.

0250-4e52 pools more than one route, so I matched frames rather than the STID. This is the Merge + row-policy route, not the object-storage _path prefilter that the same STID also carries.

Aborting query (fatal.log, query_id 668ebd4b-542b-47a9-acc1-10a8531416d4):

SELECT * FROM merge(currentDatabase(), '^row_policy_table$') FINAL ORDER BY id DESC

query_log gives log_comment = 04509_row_policy_arrayjoin_filter.sh. That test creates valid_policy ON row_policy_table FOR SELECT USING value IN (SELECT arrayJoin([10, 20])) (14:17:17.352 to .376) and then runs a plain SELECT * FROM row_policy_table ORDER BY id. The server-side AST fuzzer rewrote that into the query above: QueryFuzzer::wrapTableAsMerge (src/Common/QueryFuzzer.cpp:3502, called at :5910) plus the FINAL toggle at :5906. The query carries no IN of its own, so the only set in the filter is the policy predicate's.

ReadFromMerge::RowPolicyData::addFilterTransform (src/Storages/StorageMerge.cpp:1929-1933 on master) plants the policy's FilterStep, and nothing builds its IN subqueries; addStorageFilter is only an additional pushdown and does not cover FINAL. So FilterTransform::doTransform reaches FunctionIn::executeImpl (src/Functions/in.cpp:128) with an unbuilt set, under the fuzzer's CompletedPipelineExecutor. That is the stack in this report.

#114058 changes exactly that site: it keeps the analyzer's prepared_sets on RowPolicyData and plants addDelayedCreatingSetsStep in addFilterTransform. Its first test arm is the same shape, merge(...) FINAL over a table whose policy is value IN (SELECT 10). Master still has the unfixed three-line addFilterTransform, so the route is live. #114058 has had no review since it was opened, and it is 24 days behind master so it needs a fresh CI run; I can refresh it whenever you want.

By frames over 30 days, the family splits into 462 rows on the object-storage construction shape and 248 on this runtime-filter shape (197 distinct PRs, 11 true-master rows).

On the two integration shards: confirmed from the report, both 5/6 and 6/6 are Container memory budget exceeded (/docker). Since #117412 that row is concentrated on 6/6 (96 of 501 trees in my sample; 1/6 through 4/6 at zero), and the remainder there is a session-scoped-fixture container leak, which my #117564 addresses.

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 2026
Every `instance.query` of the integration test framework starts its own
`clickhouse-client` process, which costs about half a second regardless of what
the statement does. The setup created the `_sender` table and the `_watcher`
view of each system log table with one call per table, so with the ~17 log
tables of a default instance it spent ~11 s on every server of every test - and
that is most of an integration test job's wall clock: on the previous run all
six `Integration tests (amd_asan_ubsan, db disk, old analyzer)` shards took
~7350-7420 s against ~6240 s on `master`, and five of them were killed by the
7200 s pytest session timeout.

Discovery (`SYSTEM FLUSH LOGS` and the structure query) and the DDL are now one
call each. The list of exported tables is no longer assumed from the statements
that were sent: the batch ends with a query for the `_watcher` views that
actually exist, so a partial failure does not make the shutdown flush reference
a `_sender` table which was never created.

Report of the run this is measured from:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116031&sha=70f1e429b29ef2d5d62684eb2569364063e587d9&name_0=PR
Comment thread tests/integration/helpers/cluster.py Resolved
alexey-milovidov and others added 3 commits October 14, 2026 15:56
…the CI logs backfill

The first enable of the export after `restart_with_latest_version` now
records on the instance that the backfill must exclude the rows of the old
release, together with the start time of the binary under test, taken once.
`refresh_after_start` uses the same boundary for the tables whose setup failed
at that point and is retried at a later restart, instead of sending the whole
table. If the first setup failed before taking the boundary, the start of the
current server is used, which loses rows rather than exporting the old ones.

The `INSERT ... SELECT` that sends the rows the log tables already hold runs
as the test user, not through the `DEFINER = ci_logs_sender` views, and
`DistributedSink` replays its settings on the CI Logs cluster. It now carries
the settings of the `ci_logs_sender` profile (parsed from the same
`tests/config/users.d/ci_logs_sender.yaml`) and `max_execution_time = 0`, so
the short timeouts, background sends and memory limits apply to it too, and a
test-specific `max_execution_time` does not break the setup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion tests

`run_and_check` logged the whole environment of a failed command, which for
Keeper startup is a copy of `os.environ` and holds
`CLICKHOUSE_CI_LOGS_PASSWORD`, and `exec_in_container` printed the complete
`inspect_container` result of a failed exec, whose `Config.Env` holds the
password the docker compose section passes to the instance. Both outputs are
collected as CI artifacts.

The new `helpers/redact.py` masks the values of the variables whose names look
like secrets (the same pattern the `ClickHouseCluster` constructor already used
for its environment dump), and both diagnostics, as well as the log of
`_create_env_file`, go through it. A sentinel-value test covers both paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The only red check on 00f6db8 is CH Inc sync (tests failed). All public CI jobs are green.

  • test_shared_merge_tree_system_log_pipeline/test.py::test_shared_merge_tree_system_log_pipeline and ::test_startup_does_not_abort_when_credentials_hard_fail (private Integration tests 5/8 on amd_asan_ubsan db disk, amd_tsan and amd_msan) are caused by this PR. The test waits until SELECT name FROM system.tables WHERE name LIKE '%text_log%' returns exactly the four log pipeline tables. With the export enabled, that pattern also matches system.text_log_sender and system.text_log_watcher, so the condition is never met. test_azure.py has the same check. I pushed 09df1d8b6a8 to the sync branch, which selects the four pipeline tables by their exact names.
  • test_per_log_smt_keys (amd_msan) failed with NETWORK_ERROR after the OOM killer stopped the server (Container memory budget exceeded (/docker)). It is an infrastructure failure, not an assertion failure.
  • test_distributed_stateless_part2::test_lazy_index_granularity_for_non_uniform_parts (amd_tsan), 05359_parquet_file_logical_type (FIPS) and 04238_alter_rename_column_merge_race (already tracked in a private issue) are in areas this PR does not touch.

alexey-milovidov and others added 2 commits October 25, 2026 06:23
…tops answering

When the probe succeeded but the CI Logs cluster stopped answering while the
destination tables were created, every remaining table waited for the DDL and
the existence check timeouts, and so did every later server, because the
`connected` marker skipped the probe. Now an existence check that fails with a
timeout or a connection error stops the setup and writes the `lost` marker,
which disables the export for the rest of the job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master in 04c30c7 (no conflicts, PR diff unchanged) to pick up fixes for both red jobs on 9266939, neither caused by this PR:

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master in 18ed490 (no conflicts, PR diff unchanged) to keep the branch current; CI on the previous head was green and there are no unresolved review threads.

…g_tables`

`test_stable_with_non_default_create_settings` checked that `query_log` is not
rotated by counting the tables matching `query\_log\_%`. In CI, the export of
the system logs creates `system.query_log_sender` and `system.query_log_watcher`
on every instance, so the count was 2. Match only the rotated versions
(`^query_log_[0-9]+$`).

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116031&sha=18ed490cd3dd2a539fbfe90d25d158019150b6fe&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%202%2F4%29
#116031

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The red Integration tests (arm_binary, 2/4) on 18ed490 was caused by this PR: test_create_union_system_log_tables/test.py::test_stable_with_non_default_create_settings checked that query_log was not rotated by counting query\_log\_% tables, and that pattern also matches the system.query_log_sender / system.query_log_watcher objects the export creates (hence 2 != 0). Fixed in e9810cc by matching only the rotated versions (^query_log_[0-9]+$). No unresolved review threads.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master in 7b9b2cf (no conflicts, PR diff unchanged). All public CI jobs on the previous head were green. The only red check was CH Inc sync, where the bot could not merge private master into the sync branch.

The conflicts were in the private-only test_shared_merge_tree_system_log_pipeline tests. Private master refactored them: it deleted test_migration_and_rollback.py, test_mixed_schema.py and test_transposed_metric_log.py, added test_toggle.py, and changed its table checks to use exact names, so the old %text_log% adaptation is no longer needed. I took the master versions and added with_ci_logs_export=False to every add_instance in test.py, test_azure.py and test_toggle.py. I pushed this to the sync branch as 204fd2e67bb; it also records 7b9b2cf as a parent. The sync PR is now MERGEABLE.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master in edf22b9 (no conflicts, PR diff unchanged).

The only red job on 7b9b2cf was Integration tests (arm_binary, distributed plan, targeted): test_grpc_protocol/test.py::test_ipv6_select_one timed out in grpc.channel_ready_future (grpc.FutureTimeoutError). This PR does not touch gRPC, and the same test fails in the same job on many unrelated PRs since 2026-11-15 (e.g. #132862, #132882, #122051, #132317, #132826, #132827).

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116031&sha=7b9b2cf9cea37f60257e9ec212b3587d14af9337&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%20targeted%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is #132156, merged 2026-11-19 17:49 UTC.

Root cause: test_keeper_ipv4_fallback ran sysctl -w net.ipv6.conf.all.disable_ipv6=1 (then =0) in the job container's network namespace, which every test in the job shares. The restore does not bring back dockerd's static fd00::1, so a later IPv6 connect made while the new compose bridge address is still in DAD picks a link-local source and hangs past the 10 s channel_ready_future timeout. The targeted job runs test_grpc_protocol after that module, and the release arm_binary server comes up fast enough to connect inside that window. #132156 deletes the module (CI cannot emulate ipv6.disable=1 with it anyway).

The red run on 7b9b2cf started 2026-11-18 12:52 UTC, before the fix merged; edf22b97a03d includes it. Since the merge, CIDB has no failure of this test in a run whose tree contains the fix.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, thanks for confirming that #132156 fixes the test_grpc_protocol failure. edf22b97a03d already contains it.

The only red check on edf22b97a03d was CH Inc sync. The sync PR conflicted with private master in test_shared_merge_tree_system_log_pipeline/test.py, where private master added config/system_local.xml to the instance config next to the with_ci_logs_export=False adaptation. I pushed 33b66da6024 to the sync branch with both changes kept. Its diff against private master is the 27 files of this PR plus the three private-only with_ci_logs_export=False adaptations, and the sync PR is now MERGEABLE. This PR needs no code change.

@stresshouse

stresshouse Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 29 queries analysed

no significant changes detected. K_source=4 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: c31439fb-2432-4e08-a082-bafe73cba27e
  • MIRAI run: 1710adf0-ee08-4d7a-9a89-30b0729b27af
  • PR check IDs:
    • clickbench_863557_1795384565
    • clickbench_863572_1795384565
    • tpch_adapted_1_official_863600_1795384565
    • tpch_adapted_1_official_863619_1795384566

… does not match them

The export kept its local `Distributed` table and materialized view as
`system.<table>_sender` and `system.<table>_watcher`. The built-in
`system.dashboards` read the logs with
`clusterAllReplicas(default, merge('system', '^asynchronous_metric_log'))`,
which also matched `system.asynchronous_metric_log_sender`, so the read was
forwarded to the CI Logs cluster, where the export user has no `SELECT` grant:

    Code: 497. DB::Exception: Received from ...clickhouse-staging.com:9440.
    DB::Exception: ci: Not enough privileges. To execute this query, it's
    necessary to have the grant SELECT(...) ON
    default.asynchronous_metric_log_6455819470331241870. (ACCESS_DENIED)

This failed `test_distributed_cache/test.py::test_server_dashboard_per_host`
in the private sync of this PR:
ClickHouse/clickhouse-private#70455

The objects are now `system.ci_logs_export_<table>_sender` and
`system.ci_logs_export_<table>_watcher`: they neither start with the name of a
log table nor end with `_log`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 CH Inc sync was red with tests failed on the private sync PR (ClickHouse/clickhouse-private#70455). One of the failures was caused by this PR. I fixed it in 7a8273a.

  • test_distributed_cache/test.py::test_server_dashboard_per_host (amd_msan, amd_tsan, amd_asan_ubsan) failed with ACCESS_DENIED ... SELECT ... ON default.asynchronous_metric_log_<hash>, received from the CI Logs cluster. The built-in system.dashboards read clusterAllReplicas(default, merge('system', '^asynchronous_metric_log')). That pattern also matched the export's Distributed table system.asynchronous_metric_log_sender, so the dashboard read went to the CI Logs cluster. The export's local objects are now system.ci_logs_export_<table>_sender and system.ci_logs_export_<table>_watcher. They no longer start with a log table name or end with _log. I added a test for this to ci/tests/test_ci_logs_export_images.py; all 34 tests there pass locally, and ruff is clean.
  • Unrelated: the sanitizer reports at server exit in S3::ClientCacheRegistry::unregisterClient (test_distributed_cache teardown errors). They are a static destruction order problem in the server, and Fix a crash at shutdown when a static still owns an S3 client #133151 is open to fix them.
  • Unrelated: the private-only stateless test 04836_shared_merge_tree_create_with_leftovers failed with a Keeper error (Child "data" of object 1 was modified by a concurrent transaction). It also fails on other sync PRs.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The only red check on 7a8273a is CH Inc sync (tests failed (1 new, 1 known)); all public CI jobs are green and there are no unresolved review threads. No changes were needed in this PR.

Both failures are in one private job, Stateless tests (amd_fips_release, meta in keeper, s3 storage, OpenSSL FIPS, parallel) of ClickHouse/clickhouse-private#70455, and neither is caused by this PR, which changes only the integration tests and the CI log export scripts:

I re-ran the failed job of the private run.

@groeneai, investigate the failure of 04780_json_subcolumn_index_match_not_quadratic: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=ef4eb6170435e1aed3fa33ad49b7003c11f7c464&name_0=MasterCI&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.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is in progress: #132825 (test-only, open, approved, CI green, waiting for a merge).

The master run you linked has the same signature as the other hits since 2026-11-15: the withjson dotted query read 17,979,928 bytes, its normal value, against a no-dots control of 11,599,512 bytes (35% low); the private FIPS run (17,975,016 vs 11,592,616) is the same. MemoryAllocatedWithoutCheckBytes also depends on flushes triggered by other threads on the same CPU, so under parallel load the control can read low. #132825 compares the queries' peak memory_usage with --max_untracked_memory 0 instead, keeping the three runs and the 150% bound.

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.

2 participants