Repository navigation
Export system logs to the CI Logs cluster from integration tests - #116031
alexey-milovidov wants to merge 68 commits into
Conversation
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.
|
Workflow [PR], commit [7a8273a] Summary: ✅
AI ReviewSummaryThe 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 Missing context / blind spots
Final VerdictStatus: ✅ Approve |
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.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline. |
…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.
…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.
|
🕵 @groeneai, investigate the failure of It is unrelated to this PR (which only touches the CI logs export and the integration-test helpers): the test also fails on |
|
Root cause is in The destination path is scoped to The conditional 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 ( One correction on the CI database counts. Scoping true master as |
…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]>
|
🕵 @groeneai, investigate the failure: Stress test (arm_debug) - |
|
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.
Aborting query ( SELECT * FROM merge(currentDatabase(), '^row_policy_table$') FINAL ORDER BY id DESC
#114058 changes exactly that site: it keeps the analyzer's 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 |
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
…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]>
|
🕵 The only red check on 00f6db8 is
|
…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]>
|
🕵 Merged
|
|
🕵 Merged |
…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]>
|
🕵 The red |
|
🕵 Merged The conflicts were in the private-only |
|
🕵 Merged The only red job on 7b9b2cf was @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. |
|
The fix is #132156, merged 2026-11-19 17:49 UTC. Root cause: The red run on 7b9b2cf started 2026-11-18 12:52 UTC, before the fix merged; |
|
🕵 @groeneai, thanks for confirming that #132156 fixes the The only red check on |
|
📊 Cloud Performance Report ✅ AI verdict: 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
|
… 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]>
|
🕵
|
|
🕵 The only red check on 7a8273a is Both failures are in one private job,
I re-ran the failed job of the private run. @groeneai, investigate the failure of |
|
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 |
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) andnode_name(the instance name within the cluster, e.g.node1). Functional tests, stress tests and fuzzers fill them with empty strings.test_nameis also added to the destination tables'ORDER BY(aftercheck_name) and gets aset(100)skip index.How it works (the new helper
tests/integration/helpers/ci_logs_export.py, the integration-tests counterpart ofsetup_log_cluster.sh):After a cluster starts, each eligible instance gets a Distributed
system.<table>_sendertable and asystem.<table>_watchermaterialized view persystem.*_logtable, 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 onessetup_log_cluster.shcomputes, so functional and integration tests share the destination tables.The
_watcherviews are created withDEFINER = ci_logs_senderandtests/config/users.d/ci_logs_sender.yaml- the very config the functional tests,clickbench,sqlstormand the fuzzers install - is copied into the instanceusers.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 thedefaultprofile 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 newhelpers.ci_logs_export.without_sender_user. The row policy suite needs it because with the access control improvements disabledUsersConfigParser::parseRowPoliciesgenerates a permissive policy for every user of the users config, soci_logs_senderadds one per table. The remaining access-control suites compare contiguousSHOW ACCESSblocks 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-testimage and the images derived from it (currentlyclickhouse/integration-test-with-unity-catalog, used bytest_database_delta), each at the tag built for the current commit, plus everywith_installed_binaryinstance whatever its image is - the binary under test is mounted into those containers as/usr/share/clickhouse_freshandrestart_with_latest_versionswaps the server to it. That is eligibility of the container (ci_logs_export_supported); whether the export is on right now isci_logs_export_enabled, which starts false for awith_installed_binaryinstance:restart_with_latest_versioninstalls the configs before the fresh binary starts and sets the export up once the server is up, andrestart_with_original_versionflushes, drops the_sender/_watchertables and removes the configs first. So the upgraded phase oftest_statistics_minmax_upgrade,test_version_updateand the rest is exported, while the old-release phases stay out. TheCLICKHOUSE_CI_LOGS_*variables are passed to every supported container at creation, because the config written at the swap resolves them withfrom_envand a server that cannot resolve one refuses to start.ci/tests/test_ci_logs_export_images.pyderives the expected image set from theFROMlines of the Dockerfiles underci/docker/integrationand fails if a new derived image is missing from the map or if its tag environment variable diverges fromIMAGES_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.querystarts its ownclickhouse-clientprocess, which costs about half a second whatever the statement does, so the setup is two round trips per server:SYSTEM FLUSH LOGSplus the structure query, then all theCREATEstatements at once, ending with a query for the_watcherviews that actually exist (a partial failure must not leave the shutdown flush referencing a_sendertable 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 of70f1e429all sixIntegration tests (amd_asan_ubsan, db disk, old analyzer)shards took ~7350-7420 s against ~6240 s onmaster, 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.clustersandsystem.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_senderuser is declared with a randompassword_sha256_hexrather thanno_password: a server started withallow_no_password: 0refuses 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 theDEFINERof the_watcherviews.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 LOGSper server put the shards at 6.9-7.4 ks against amasterp50 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):
from_envandhide_in_preprocessed="1"(verified thatpreprocessed_configsomits 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 theCLICKHOUSE_PASSWORDenvironment variable instead of the command line. The environment dump incluster.pynow masks variables matchingPASSWORD|SECRET|TOKEN|ACCESS_KEY.shard1_replica1), so no credentials appear under the instancedatabase/directory either.Tested locally end-to-end: a real
ci.praktikaintegration run oftest_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 correcttest_name/node_name, the destination table names matched the hashes computed by thesetup_log_cluster.shmethod exactly, and no credential values appeared anywhere under_instances*/.The
ci_logs_senderpart was verified the same way: the YAML inusers.ddefines the user and the profile, every_watcherview getsdefiner = '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_user0 instead of 5000000000,async_insert1 instead of 0,send_timeout15 instead of 300,distributed_foreground_insert0 instead of 1,enable_filesystem_cache_on_write_operations0 instead of 1).test_grant_and_revoke::test_introspectionpasses with the export enabled.Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/116031]