Skip to content

CI: fix performance-test server killing its own driver via shared process group - #103307

Merged
leshikus merged 2 commits into
ClickHouse:masterfrom
leshikus:add-ci-tests-init
May 8, 2026
Merged

leshikus merged 2 commits into
ClickHouse:masterfrom
leshikus:add-ci-tests-init

Conversation

@leshikus

@leshikus leshikus commented Apr 21, 2026 •

Copy link
Copy Markdown
Collaborator

CHServer.start and CHServer.start_preconfig in ci/jobs/performance_tests.py launched the server with shell=True but without start_new_session=True, so the server process inherited the driver's process group. Utils.terminate_process_group then called os.killpg(pgid, SIGTERM) on that shared group, killing the driver along with the server. This was masked when the driver ran as PID 1 (immune to SIGTERM by default); adding --init in #102529 made it visible — the driver now exits with code 143.

Fix: start_new_session=True on both Popen calls in CHServer. Also restores --init in runner.py and removes the temporary --skip test_cleanup_kills_orphaned_test_process workaround.

Also cleans up ClickHouseService in ci/jobs/scripts/clickhouse_service.py: replaces the self._log_fd instance attribute with a with open(...) block in __enter__ (the parent's fd is safely closed after Popen since the child retains its own copy via dup2) and removes the now-dead flush() and close() calls.

Changelog category (leave one):

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

Version info

  • Merged into: 26.5.1.425

@leshikus leshikus changed the title CI: fix perf-test SIGTERM by using start_new_session=True, restore --init Fix performance-test driver killed by its own SIGTERM when running under tini Apr 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7e8506c]

Summary: ✅
Keeper Stress Tests (PR): Grafana: Run details (this run), Grafana: 1vs1 Comparison, Grafana: Historical progression


AI Review

Summary

This PR fixes CI process-lifecycle handling by isolating clickhouse-server into its own session/process group in performance_tests.py, restoring Docker --init in Praktika runner invocation, removing a temporary CI Tests skip workaround, and simplifying ClickHouseService log file descriptor handling. I did not find correctness, safety, or reliability issues in the current diff.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 21, 2026
Comment thread ci/jobs/ci_tests_job.py Resolved
Comment thread ci/jobs/ci_tests_job.py Resolved
Comment thread ci/jobs/scripts/clickhouse_service.py Resolved
azat pushed a commit to azat/ClickHouse that referenced this pull request Apr 23, 2026
PR ClickHouse#101267 removed the 15-iteration retry loop with the claim that the new
caching-based sampling ensures a single pass produces all expected trace-log
rows. After the PR was merged to master, the test began failing on both
master (`Integration tests (amd_binary_excluded_from_llvm)`) and several
unrelated in-flight PRs (ClickHouse#98727, ClickHouse#101434, ClickHouse#103307), each at different
assertion lines in the single-pass test:

- `get_trace_events('Unknown', 'Global', 'JemallocSample') > 0`
- `get_trace_events('Unknown', 'Max', 'MemorySample', query_id) > 0`
- `get_trace_events('Global', 'Max', 'Memory'/'MemoryPeak') > 0`

The reason these events are not guaranteed in a single pass — even with
fully-propagated `sample_probability` — is that two of the trace types are
genuinely probabilistic relative to this test's workload:

- `JemallocSample` is emitted by `jemalloc`'s own profile sampler
  (`lg_prof_sample=20` ≈ one sample per 1 MiB). Ten `logTrace('foo')` calls
  plus a `SELECT * FROM numbers(100000) ORDER BY number` are not guaranteed
  to allocate enough `jemalloc`-tracked memory to trigger a sample inside a
  `MemoryTrackerBlockerInThread(Global)` scope.
- `Memory`/`MemoryPeak` with `memory_context = 'Global'` are only emitted
  when `total_memory_tracker` crosses its `total_memory_profiler_step`
  watermark (4 MiB default). Whether this happens inside a given test
  query depends on cumulative server-wide allocations including background
  activity, not just the query's own allocations.

The retry loop bounds the test runtime at ~15 s while letting these
events accumulate reliably. Restore it, and add a comment explaining
why it is required so it is not dropped again.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=fa205863ba68f05b529e2073defb5cf5df7cc832&name_0=MasterCI&name_1=Integration%20tests%20%28amd_binary_excluded_from_llvm%29

Session: cron:clickhouse-ci-task-worker:20260421-224500

Co-Authored-By: Claude Opus 4.7 <[email protected]>
euvre pushed a commit to euvre/ClickHouse that referenced this pull request Apr 24, 2026
…ut-init

CI: re-add CI Tests job; skip orphan-cleanup test until latent bug in performance_tests.py is fixed (ClickHouse#103307)
@leshikus
leshikus marked this pull request as ready for review April 24, 2026 18:03
leshikus added a commit to leshikus/ClickHouse that referenced this pull request Apr 26, 2026
… build

The Stage 1 instrumented clang was compiled with the default value-profiling
counter limit of 3 slots per indirect call site. During ClickHouse profile
collection, the instrumented binary emitted:

  LLVM Profile Warning: Unable to track new values: Running out of static
  counters.  Consider using option -mllvm -vp-counters-per-site=<n> to
  allocate more value profile counters at compile time

This saturates call-site counters and loses indirect-call frequency data
needed by the PGO optimizer in Stage 2, reducing the quality of the final
toolchain.

Fix: pass `-mllvm -vp-counters-per-site=8` via `CMAKE_C_FLAGS` /
`CMAKE_CXX_FLAGS` when building Stage 1. The flag is baked into the
instrumented binary at compile time, so the running binary can track up to
8 distinct callees per indirect call site instead of 3.

Seen in: ClickHouse#103307

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
leshikus added a commit to leshikus/ClickHouse that referenced this pull request Apr 27, 2026
…-serialization`

PR ClickHouse#102596 (`yarik/fix-time64-serialization`) added a trailing-garbage
check in `deserializeTextCSV`: after parsing the unquoted field as a
time string, it now throws `UNEXPECTED_DATA_AFTER_PARSED_VALUE` if the
buffer is not fully consumed.

The test was using `45045123` as an unquoted CSV value. `readTime64Text`
parsed only `45` (SS format) and left `045123` as "trailing garbage",
causing the test to fail across all stateless-test configurations.

Fix: replace the raw integer with `12:30:45.123`, a proper unquoted time
string, and rename the section header accordingly. The expected output
(`00:00:00.000` / `12:30:45.123`) is unchanged since the quoted-CSV and
unquoted time-string paths both normalise correctly.

Ref: ClickHouse#103307

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread ci/praktika/native_jobs.py Resolved
@leshikus
leshikus requested a review from maxknv April 27, 2026 13:16
Comment thread ci/praktika/workflow.py Resolved

@maxknv maxknv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd like to see the Praktika change land separately - it's a significant update and shouldn't go in as a side fix.
Two suggestions:

  1. The new label shouldn't be a per-workflow property. It feels more like a basic debugging feature, so it should be a new Setting in Praktika that users can override when needed.
  2. I'd suggest naming the label ci-force-all

@maxknv maxknv self-assigned this Apr 28, 2026
Comment thread ci/praktika/workflow.py Resolved
@leshikus leshikus added the ci-force-all Do not skip any jobs when running label Apr 30, 2026
@leshikus leshikus changed the title Fix performance-test driver killed by its own SIGTERM when running under tini CI: fix performance-test server killing its own driver via shared process group Apr 30, 2026
commit 600be4aa8a8613d0a4ba9b7e8ad846f789dc93ba
Merge: febefb0 4e4a4c0
Author: Alexei Fedotov <[email protected]>
Date:   Sat May 2 13:48:18 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit febefb0
Author: Alexei Fedotov <[email protected]>
Date:   Fri May 1 01:13:37 2026 +0200

    Remove unimplemented `job_filter_bypass_labels` field from `Workflow.Config`

    The field was declared but never consumed by the job filtering logic in
    `native_jobs.py`, so `"ci-all-jobs"` label would have had no effect.
    Also reverts the `BUILD_TOOLCHAIN (amd64)` timeout override that was
    included in the same commit by mistake.

commit bca4a1f
Merge: fa4ec08 a0aae2a
Author: Alexei Fedotov <[email protected]>
Date:   Fri May 1 01:03:46 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit fa4ec08
Merge: 062b466 d3573bd
Author: Alexei Fedotov <[email protected]>
Date:   Tue Apr 28 07:59:44 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit 062b466
Author: Alexei Fedotov <[email protected]>
Date:   Mon Apr 27 15:12:22 2026 +0200

    Revert "Address review: keep release-PR guard unconditional when `ci-all-jobs` label is set"

    This reverts commit e9f8a95.

commit e9f8a95
Author: Alexei Fedotov <[email protected]>
Date:   Mon Apr 27 15:07:34 2026 +0200

    Address review: keep release-PR guard unconditional when `ci-all-jobs` label is set

    Add `job_filter_bypass_exclude_labels` to `Workflow.Config`. When any of those
    labels are present, `job_filter_bypass_labels` is ignored so `workflow_filter_hooks`
    and file-based job filtering both run normally.

    Configure `pull_request.py` with `job_filter_bypass_exclude_labels=["release",
    "release-lts"]` so a PR carrying both `ci-all-jobs` and a release label still has
    every job skipped by the `should_skip_job` release guard, consistent with the PR
    description ("Release labels still take priority").

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit c07de66
Author: Alexei Fedotov <[email protected]>
Date:   Mon Apr 27 13:09:24 2026 +0200

    Fix `04122_serialization_time64_formats` test after `yarik/fix-time64-serialization`

    PR ClickHouse#102596 (`yarik/fix-time64-serialization`) added a trailing-garbage
    check in `deserializeTextCSV`: after parsing the unquoted field as a
    time string, it now throws `UNEXPECTED_DATA_AFTER_PARSED_VALUE` if the
    buffer is not fully consumed.

    The test was using `45045123` as an unquoted CSV value. `readTime64Text`
    parsed only `45` (SS format) and left `045123` as "trailing garbage",
    causing the test to fail across all stateless-test configurations.

    Fix: replace the raw integer with `12:30:45.123`, a proper unquoted time
    string, and rename the section header accordingly. The expected output
    (`00:00:00.000` / `12:30:45.123`) is unchanged since the quoted-CSV and
    unquoted time-string paths both normalise correctly.

    Ref: ClickHouse#103307

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit 0ebb9c7
Author: Alexei Fedotov <[email protected]>
Date:   Mon Apr 27 13:09:14 2026 +0200

    Move `ci-all-jobs` bypass out of filter hooks into the call site

    `job_filter_bypass_labels` was only checked in the file-based filtering
    phase of `_config_workflow`, so `workflow_filter_hooks` (e.g.
    `private_job_filter`) still ran and skipped jobs even when the
    `ci-all-jobs` label was set.

    Fix: check `job_filter_bypass_labels` before iterating
    `workflow_filter_hooks` in `native_jobs.py` so the bypass is applied
    uniformly to all hook-based filtering, not just file-based filtering.

    The now-redundant early-return for `Labels.CI_ALL_JOBS` inside
    `should_skip_job` is removed — it is dead code once the call site
    handles the bypass.

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit dc35478
Author: Alexei Fedotov <[email protected]>
Date:   Mon Apr 27 08:54:44 2026 +0200

    Fix race condition and error masking in `test_accept_invalid_certificate`

    `execute_query_native` wrote all test configurations to the same
    `configs/client.xml` path, causing parallel test invocations to
    clobber each other's config and produce inconsistent TLS behaviour.
    Additionally, calling `remove()` inside the `except` block could raise
    `FileNotFoundError`, which replaced the real SSL exception and broke
    the `assert "certificate verify failed"` checks.

    Fix: write each config to a unique temp file via `tempfile.mkstemp` and
    clean it up in a `finally` block that swallows `FileNotFoundError`.

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit 263d43a
Merge: 5176553 c37e307
Author: Alexei Fedotov <[email protected]>
Date:   Mon Apr 27 08:50:41 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit 5176553
Author: Alexei Fedotov <[email protected]>
Date:   Sun Apr 26 09:48:31 2026 +0200

    CI: fix `LLVM Profile Warning: Running out of static counters` in PGO build

    The Stage 1 instrumented clang was compiled with the default value-profiling
    counter limit of 3 slots per indirect call site. During ClickHouse profile
    collection, the instrumented binary emitted:

      LLVM Profile Warning: Unable to track new values: Running out of static
      counters.  Consider using option -mllvm -vp-counters-per-site=<n> to
      allocate more value profile counters at compile time

    This saturates call-site counters and loses indirect-call frequency data
    needed by the PGO optimizer in Stage 2, reducing the quality of the final
    toolchain.

    Fix: pass `-mllvm -vp-counters-per-site=8` via `CMAKE_C_FLAGS` /
    `CMAKE_CXX_FLAGS` when building Stage 1. The flag is baked into the
    instrumented binary at compile time, so the running binary can track up to
    8 distinct callees per indirect call site instead of 3.

    Seen in: ClickHouse#103307

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit 22a4eb5
Author: Alexei Fedotov <[email protected]>
Date:   Sun Apr 26 00:17:19 2026 +0200

    Update workflows

commit e281776
Merge: 807b47f 7fc29dc
Author: Alexei Fedotov <[email protected]>
Date:   Sun Apr 26 00:16:47 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit 807b47f
Author: Alexei Fedotov <[email protected]>
Date:   Sun Apr 26 00:08:57 2026 +0200

    CI: increase `Build Toolchain (PGO, BOLT) (amd64)` timeout to 8 h on PR

    3 h was too tight; raise to 8 h to match the previous default.

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit eb73037
Author: Alexei Fedotov <[email protected]>
Date:   Sat Apr 25 10:55:39 2026 +0200

    Update workflows

commit 30ba815
Merge: 8154744 04bd709
Author: Alexei Fedotov <[email protected]>
Date:   Sat Apr 25 10:54:58 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit 8154744
Author: Alexei Fedotov <[email protected]>
Date:   Sat Apr 25 10:22:14 2026 +0200

    CI: fix flaky check assertion and toolchain timeout on PR

    - In `integration_test_job.py`, fall back to a sanity test when `is_flaky_check` is True, no changed integration test modules are found, and `ci-all-jobs` label is set (which bypasses job skips and would otherwise hit the assertion)
    - In `pull_request.py`, override timeout to 3 hours for `Build Toolchain (PGO, BOLT) (amd64)` in the PR workflow

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit 040de15
Author: Alexei Fedotov <[email protected]>
Date:   Fri Apr 24 19:51:10 2026 +0200

    CI: fix `_log_fd` leak in `ClickHouseService` when `Popen` raises

    Use a `with` block so the log file descriptor is always closed after
    `subprocess.Popen` returns, whether it raises or not. The child process
    holds its own dup'd fd, so closing Python's copy is safe. Removes the
    now-unnecessary `_log_fd` instance variable and its associated
    `flush`/`close` calls.

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit 1eeef90
Author: Alexei Fedotov <[email protected]>
Date:   Fri Apr 24 19:38:55 2026 +0200

    CI: add `ci-all-jobs` label to bypass all job skips

    Add a new `ci-all-jobs` PR label that disables both filter-hook skips
    and file-based job filtering, so every job in the workflow runs
    regardless of changed files or other label-based conditions. Release
    labels still take priority.

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit f265406
Author: Alexei Fedotov <[email protected]>
Date:   Fri Apr 24 19:25:35 2026 +0200

    Restore --init

commit 72fda4b
Merge: 7fcb083 cf81ad1
Author: Alexei Fedotov <[email protected]>
Date:   Fri Apr 24 19:24:06 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit 7fcb083
Author: Alexei Fedotov <[email protected]>
Date:   Wed Apr 22 22:05:03 2026 +0200

    ci: resolve merge conflict in `ci_tests_job.py`

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

commit 5cac837
Merge: 8d8f5a1 3f97d3d
Author: Alexei Fedotov <[email protected]>
Date:   Wed Apr 22 12:07:22 2026 +0200

    Merge branch 'master' into add-ci-tests-init

commit 8d8f5a1
Author: Alexei Fedotov <[email protected]>
Date:   Tue Apr 21 23:42:06 2026 +0200

    CI: fix perf-test SIGTERM by using start_new_session=True, restore --init

    The performance test driver was being killed by its own `SIGTERM` because
    `Utils.terminate_process_group` called `os.killpg(os.getpgid(child_pid), SIGTERM)`,
    but the child server inherited the driver's own process group (since `subprocess.Popen`
    was called with `shell=True` and no session isolation).  With `--init` injecting
    `tini` as PID 1 the driver was no longer immune to `SIGTERM`, so the bogus
    `killpg` killed it — producing "Job killed, exit code [143]".

    Root-cause fix: add `start_new_session=True` to both `Popen` calls in
    `ci/jobs/performance_tests.py` (`start_preconfig` and `start`).  This gives
    the server its own process group, so `os.killpg` can only reach server
    processes and the driver is safe.

    With the real fix in place:
    - `--init` is restored in `ci/praktika/runner.py` (it provides correct zombie
      reaping and was correct to add in ClickHouse#102529).
    - The temporary `--skip test_cleanup_kills_orphaned_test_process` workaround
      is removed from the `CI Tests` job config; the test can now run normally.

    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@leshikus

leshikus commented May 5, 2026

Copy link
Copy Markdown
Collaborator Author

try to sync

@leshikus
leshikus added this pull request to the merge queue May 8, 2026
Merged via the queue into ClickHouse:master with commit a4abd8e May 8, 2026
165 checks passed
@leshikus
leshikus deleted the add-ci-tests-init branch May 8, 2026 08:44
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-force-all Do not skip any jobs when running pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants