Skip to content

Perf CI: stop merges in the main runs and start them before the teardown - #122073

Merged
fm4v merged 1 commit into
masterfrom
perf-ci-stop-merges-in-main-runs
Sep 25, 2026
Merged

fm4v merged 1 commit into
masterfrom
perf-ci-stop-merges-in-main-runs

Conversation

@fm4v

@fm4v fm4v commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Two fixes for --stop-merges from #121937, reported in #121937 (comment):

  1. The measured runs in CI didn't get the flag. CI runs every test through CHServer.run_test in ci/jobs/performance_tests.py and enters compare.sh at stage=get_profiles, after run_tests, so only the confirm_changes rerun passed --stop-merges. run_test now passes it too.
  2. A test whose drop query creates a mutation (ALTER TABLE ... DROP INDEX in text_index, text_index_lazy_apply, text_index_phrase_blocked, DROP COLUMN in tpch-join_algorithm-partial_merge-fixed-str) hung in teardown: with alter_sync > 0 the ALTER waits for its mutation, mutations don't run while merges are stopped, and SYSTEM START MERGES ran only after the drop queries. The ALTER ran into max_execution_time = 300, perf.py failed and left the index on the second server, breaking later tests that add a text index on the same column. perf.py now starts merges before the drop queries; the measured queries still run with merges stopped.

Fix 2 must land with fix 1, otherwise these four tests fail on every run.

Related: #121937

Changelog category (leave one):

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

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

Version info

  • Merged into: 26.10.1.652-master (included in 26.10 and later)

The main runs of the performance job go through `CHServer.run_test`, which did not pass `--stop-merges`, so only the `confirm_changes` reruns stopped merges. And a drop query that creates a mutation, such as `ALTER TABLE ... DROP INDEX`, waited for it until `max_execution_time` because `SYSTEM START MERGES` ran only after the drop queries.

#121937 (comment)
Related: #121937
@clickhouse-gh

clickhouse-gh Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b05ff46]

Summary: ❌

job_name test_name status info comment
Performance Comparison (arm_release, master_head, 5/6) FAIL Performance dashboard
read_in_reverse_order_final #0 FAIL dashboard IGNORED
read_in_reverse_order_final #1 FAIL dashboard IGNORED

AI Review

Summary

This PR fixes two real gaps in the performance CI runner: the main sampled runs now pass --stop-merges, and perf.py restarts merges before teardown so DROP INDEX / DROP COLUMN mutations do not deadlock behind stopped merges. The direction is right, but the new teardown ordering introduces a robustness regression: one failing connection can now prevent cleanup on every other connection, which defeats the runner's existing per-connection best-effort cleanup model.

Findings

⚠️ Majors

  • [tests/performance/scripts/perf.py:1280] Teardown is supposed to degrade per connection, but SYSTEM START MERGES now runs as a separate pre-pass over all_connections. If one server is unhealthy or its connection is already broken, this raises before any drop_query runs on the healthy server, leaving behind the very indexes / columns that later tests conflict with.
    Suggested fix: restart merges inside each connection's teardown path (before that connection's drop_query loop), or otherwise continue dropping on the remaining healthy connections and report the failure only after best-effort cleanup.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: make the merge restart part of per-connection teardown so one failed connection cannot block cleanup on the others.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 24, 2026
# creates a mutation and waits for it, and mutations do not run while merges are stopped.
if stop_merges:
for c in all_connections:
c.execute("SYSTEM START MERGES")

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.

This moves SYSTEM START MERGES into a pre-pass over all connections, but the teardown below is deliberately per-connection best-effort (setup_error_on_connection can leave one side half-broken). If START MERGES fails on just one server here, we raise before any drop_query runs on the healthy side, so leftover indexes/columns leak into later tests. Previously the surviving server(s) were still cleaned up before any failure was surfaced. Please restart merges inside each connection's teardown path, or otherwise make sure one bad connection cannot skip cleanup on the others.

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 24, 2026
@fm4v
fm4v added this pull request to the merge queue Sep 25, 2026
Merged via the queue into master with commit 302e001 Sep 25, 2026
170 of 172 checks passed
@fm4v
fm4v deleted the perf-ci-stop-merges-in-main-runs branch September 25, 2026 07:37
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 25, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 25, 2026
Picks up ClickHouse#122073, which passes --stop-merges to the measured performance runs.
Before it only the confirm_changes rerun stopped background merges, so the
measured samples that feed the dashboard verdict were taken while merges ran.
The two dashboard-confirmed regressions on the previous head,
optimize_time_filter_with_preimage ClickHouse#6 and index_bulk_filtering ClickHouse#2, are of that
noise class: the shard's own report calls the first unstable and the second
successful, and neither query can reach this diff, which only parses the
vector search arguments of mergeTreeAnalyzeIndexes.
@clickgapai

Copy link
Copy Markdown
Contributor

@fm4v — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

pull Bot pushed a commit to Lobinson1/ClickHouse that referenced this pull request Sep 26, 2026
Since ClickHouse#122073 the measured perf.py runs stop merges on both servers right
after the fill. The old fill writes 54 parts in about a second, so each
server keeps whatever part set its background merges reached, and the two
servers of one run measure different layouts (21 vs 38 parts on ClickHouse#122222,
24 vs 44 on ClickHouse#122154, 22 vs 44 on master 52a67f8). FINAL ... ORDER BY
x DESC LIMIT n reads the first reverse ranges of every part (about 23K rows
each), so its time grows with the part count, and the dashboard scores the
side with more parts as a confirmed regression.

The fill now merges the first insert, stops merges on the table and writes
the second insert as exactly one part, so both servers read the same two
parts whatever the merge timing, like final_read_in_order_limit.xml:

- OPTIMIZE ... FINAL waits for the running merges before it selects, so
  the background merges of the first insert cannot leave it partial, and
  optimize_throw_if_noop = 1 makes a no-op OPTIMIZE fail with its reason
  instead of surfacing as a wrong part count.
- min_insert_block_size_rows = 16777216 (2^24, above the 10M rows) with
  min_insert_block_size_bytes = 0: the INSERT squashes on one stream before
  it fans out to the sinks and never reaches the minimum, so the whole
  insert is flushed as one part, independent of max_insert_threads,
  max_block_size and how the numbers_mt threads interleave.
- The throwIf over system.parts fails the job unless exactly 2 parts are
  active, because SYSTEM STOP MERGES on a missing table is a silent no-op.

Validated on two servers of one master release build with perf.py
--stop-merges, 5 runs per side of the change: before, 14 to 19 parts,
different on the two servers in every run, right/left up to 1.18; after,
2 parts and identical SelectedRows on both servers, right/left within 3%.

Related: ClickHouse#122073
Related: ClickHouse#121937

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

Copy link
Copy Markdown
Contributor

Update on the earlier review: CI on the proof PR #122329 confirmed the suspected bug via Stateless tests (amd_tsan, s3 storage, sequential, selected tests). Filed as a separate Issue so it isn't lost when the proof PR closes:

(Automated follow-up. The proof PR has been closed; please track the bug on the Issue.)

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 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