Skip to content

Fix flaky test_executable_udf_async_metrics by resetting the metric baseline - #108275

Merged
CheSema merged 1 commit into
ClickHouse:masterfrom
groeneai:fix/flaky-executable-udf-async-metrics-baseline
Jun 23, 2026
Merged

CheSema merged 1 commit into
ClickHouse:masterfrom
groeneai:fix/flaky-executable-udf-async-metrics-baseline

Conversation

@groeneai

@groeneai groeneai commented Jun 23, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

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

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Fixes the flaky integration test test_executable_udf_async_metrics, whose
subtests test_inflight_executable_invocation_is_visible and
test_timed_out_executable_is_killed_and_leaves_metrics fail on master and
across unrelated PRs (Integration tests (arm_binary, distributed plan, 3/4)).

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=3dc5a77be297fb233e527e3e09e9f4c7ee53716e&name_0=MasterCI&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%203%2F4%29

The tests added in #107300 measure async-metric deltas against mem_before /
procs_before snapshots. Six of the eight subtests call restart_clickhouse()
first, so they start from a clean 0/0 baseline. Three did not.

The three preceding pool tests run executable_pool UDFs and never restart
afterwards, leaving idle pool workers (each ~128 MiB) registered in the metrics.
The no-restart subtests therefore captured mem_before while that residual was
live (observed ~275 MiB across three idle workers in a local repro). Because
asynchronous_metrics refresh once per second and idle pool workers are reaped
on max_command_execution_time, the residual also shifted during the subtest's
own 25 s measurement window: when it stayed, the measured delta overshot the
one-worker band (CI saw +170..187 MiB); when a worker was reaped mid-window, the
delta went negative (CI saw -137 MiB). Both match the arm_binary failures.

Fix: have the three no-restart subtests restart and wait for the metric to
settle, matching the clean baseline the other six already establish. No
assertion is weakened.

Verified locally with the master debug binary: the full file passes 8/8 three
times with the fix; a no-restart replica of the in-flight subtest, run after the
residual is established, deterministically falls outside its band
(mem_before=275 MiB, delta=287.7 MiB).

Version info

  • Merged into: 26.6.1.1166

…aseline

The async-metric observability tests measure a delta against mem_before /
procs_before snapshots. Six of the eight subtests call restart_clickhouse()
first, so they start from a clean 0/0 baseline. Three did not:
test_inflight_executable_invocation_is_visible,
test_timed_out_executable_is_killed_and_leaves_metrics, and
test_non_udf_shell_commands_are_not_counted.

The three preceding pool tests run executable_pool UDFs and never restart
afterwards, so they leave idle pool workers (each holding ~128 MiB) registered
in the metrics. The no-restart subtests therefore captured mem_before while
that residual was live (observed ~275 MiB across three idle workers). Because
asynchronous_metrics refresh once per second and idle pool workers are reaped
on max_command_execution_time, the residual also shifted during the subtest's
own 25 s measurement window: when it stayed, the delta overshot the one-worker
band (CI saw +170..187 MiB); when a worker was reaped mid-window, the delta
went negative (CI saw -137 MiB). Both are exactly the arm_binary failures in
the report.

Fix: have the three no-restart subtests restart and wait for the metric to
settle, matching the clean 0/0 baseline the other six already establish. This
removes the residual contamination without weakening any assertion.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. Re-creating the residual the three preceding pool tests leave, then running the original (no-restart) in-flight subtest body, deterministically yields an out-of-band delta: mem_before=275 MiB, in-flight delta 287.7 MiB vs the 103-153 MiB one-worker band (in_band=False).
b Root cause explained? Yes. Six of eight subtests restart_clickhouse() before snapshotting mem_before/procs_before (clean 0/0 baseline). Three did not. The preceding executable_pool tests leave idle workers (~128 MiB each) registered in the metrics; the no-restart subtests captured mem_before while that residual was live. Async metrics refresh once/sec and idle pool workers are reaped on max_command_execution_time, so the residual shifts within the subtest's 25 s window: present -> delta overshoots (+170..187 MiB in CI); reaped mid-window -> delta goes negative (-137 MiB in CI). Both are the arm_binary failures in the report.
c Fix matches root cause? Yes. The fix gives the three no-restart subtests the same clean 0/0 baseline (restart + wait for the metric to publish) that the other six already use, removing the residual contamination at its source. It does not widen any band or disable anything.
d Test intent preserved / new tests added? Preserved. No assertion bounds, process counts, or tolerances are changed; the subtests still verify in-flight visibility, timeout cleanup, and non-UDF exclusion exactly as before. Test-only change, no source bug, so no new regression test is warranted.
e Both directions demonstrated? Yes. With the fix the full file passes 8/8 three times (master debug binary). Without the fix, a verbatim replica of the in-flight subtest run after the residual is established deterministically falls out of band (delta 287.7 MiB), reproducing the CI signature.
f Fix is general, not a narrow patch? Yes. All three subtests that lacked the restart baseline are fixed (test_inflight_executable_invocation_is_visible, test_timed_out_executable_is_killed_and_leaves_metrics, and the latent test_non_udf_shell_commands_are_not_counted), not just the two CI flagged, so the whole class of order-dependent baseline contamination is addressed.

Session id: cron:clickhouse-worker-slot-6:20260623-102400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @HanziJiang — could you review this? It fixes the flaky test_executable_udf_async_metrics subtests you added in #107300: three subtests snapshot mem_before without restarting first, so idle pool workers left by the preceding tests contaminate the baseline (the async-metric sweep then drifts that residual in or out of the measurement window). The fix gives those three the same clean baseline the other six already use; no assertions change.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9c7472a]

Summary: ✅


AI Review

Summary
  • The PR fixes a flaky test_executable_udf_async_metrics integration test by restarting ClickHouse before the three tests that previously measured async metric deltas on top of idle executable_pool worker state left by earlier tests. The change is scoped to test isolation, matches the baseline reset pattern already used by the other tests in the file, and I found no blocking or major issues.
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 23, 2026
@CheSema CheSema self-assigned this Jun 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.50% 92.50% +0.00%
Branches 77.50% 77.60% +0.10%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 405 line(s), 69 function(s) across 127 file(s) · Details

Top files
  • src/Storages/StorageReplicatedMergeTree.cpp: 36 line(s)
  • src/Databases/PostgreSQL/fetchPostgreSQLTableStructure.cpp: 23 line(s)
  • src/Common/ZooKeeper/ZooKeeper.cpp: 12 line(s)
  • src/Databases/DatabaseFactory.cpp: 11 line(s)
  • src/Parsers/parseFieldFromCastedLiteral.cpp: 10 line(s), 11 function(s)

Full report

@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

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

This PR changes only an integration test (adding clickhouse restarts for clean memory baselines) and one MongoDB documentation string — nothing in the query execution path. None of these edits can plausibly speed up ClickBench SELECTs, so the flagged improvements on Q15 (-11%), Q18 (-7%), Q28 (-6%), and Q34 (-6%) are run-to-run variance rather than real PR effects, and have been downgraded. No actionable performance change is expected from this PR.

clickbench

⚠️ 5 inconclusive

Flagged queries (5 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 15 not_sure 251 223 -11.2% <0.0001 PR only edits an integration test and an Mongo docs string; query exec path untouched, so -11% is variance
⚠️ 18 not_sure 1342 1247 -7.1% <0.0001 Test/docs-only diff cannot speed up this SELECT; -7% is run-to-run variance
⚠️ 28 not_sure 7046 6624 -6.0% <0.0001 No server hot-path change in this PR; -6% improvement is not a real PR effect
⚠️ 32 not_sure 1351 1280 -5.2% <0.0001 Already not_sure; off-path test/docs PR, treat as variance
⚠️ 34 not_sure 1482 1389 -6.3% <0.0001 PR touches only test code + docs text; -6% cannot be attributed to this change

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 8a0f729d-02b1-4798-9e73-a533e0ae8a3d
  • MIRAI run: 28cb2496-4c0e-4ac4-b450-018460ab4274
  • PR check IDs:
    • clickbench_153603_1782232531
    • clickbench_153609_1782232531
    • clickbench_153620_1782232531
    • tpch_adapted_1_official_153627_1782232531
    • tpch_adapted_1_official_153638_1782232531
    • tpch_adapted_1_official_153655_1782232531

@CheSema
CheSema enabled auto-merge June 23, 2026 17:00
@CheSema
CheSema added this pull request to the merge queue Jun 23, 2026
Merged via the queue into ClickHouse:master with commit e39ea0c Jun 23, 2026
167 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 23, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…le-udf-async-metrics-baseline

Fix flaky test_executable_udf_async_metrics by resetting the metric baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors 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.

5 participants