Skip to content

Exclude 04039_merge_tree_snapshot_teardown_race from the flaky check - #108338

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-04039-pin-codec
Jul 14, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-04039-pin-codec

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

Retargeted to master at a maintainer's request (was targeting #108093).

04039_merge_tree_snapshot_teardown_race is a long test whose runtime is dominated by 40 sleepEachRow(0.01) kill-mid-read iterations across two tables (not by compression). On the amd_msan/WasmEdge build it already runs near the 600s per-test cap (CIDB on that lane: p50 ~228s, p90 ~296s, max OK 547s, 0 FAIL on master). The flaky check reruns a test many times in one job, which reliably tips a borderline run over the cap and produces a 600s TIMEOUT FAIL. The rerun count does not change the snapshot-teardown read-pool race the test verifies, so it is marked no-flaky-check.

The earlier version of this PR pinned default_compression_codec = 'LZ4', which only mattered on the #108093 branch where the server default codec is randomized. On master the default codec is not randomized, so that pin was a no-op and was dropped in favor of the no-flaky-check tag.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. With the server default codec set to ZSTD(3) (as this branch randomizes it server-side via <merge_tree><default_compression_codec>), the test's tables inherit ZSTD; the slow compress/decompress over 8192 single-row granules pushes the amd_msan, WasmEdge run past the 600s per-test cap. CIDB confirms the single FAIL was test_duration_ms = 600260 = the hard timeout.
b Root cause explained? The branch randomizes the default column codec to LZ4 / ZSTD(1) / ZSTD(3). 04039 is long: index_granularity = 1 → 8192 single-row granules per table, 64 INSERTs + 40 kill-mid-read iterations. ZSTD compression/decompression is multiplicatively slower than LZ4. On amd_msan, WasmEdge the test already runs near the cap (CIDB 30d: p50 ~228s, p90 ~296s, max OK 547s), so the ZSTD default tips a borderline run over 600s → TIMEOUT FAIL.
c Fix matches root cause? Yes. Pin default_compression_codec = 'LZ4' on both tables, removing the ZSTD cost the randomization added. This is the same pin pattern already used on this branch for 03291/02842/03278/03261. Not a band-aid: it restores exactly the historical codec the test ran under before this branch.
d Test intent preserved? Yes. The codec is orthogonal to the snapshot-teardown read-pool race the test exercises (kill-mid-read teardown while the pool owns stripped-snapshot parts). All table layout, iterations, kill logic, and the count() = 8192 assertions are unchanged.
e Both directions demonstrated? Yes. Against a local server with the ZSTD(3) default: pre-fix the tables use ZSTD(3) (system.parts.default_compression_codec = 'ZSTD(3)'); post-fix they use LZ4 and the test passes ([ OK ] 22.5s). Verified the per-table pin overrides the ZSTD(3) server default.
f Fix is general across code paths? N/A (flaky test setting fix, not a code bug). Both CREATE TABLE statements in the test are pinned, not just the one whose run timed out.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (flaky test setting fix, not a code bug).
h Backward compatible? (maintainer-approved exception only) N/A (flaky test setting fix, not a code bug).
i Invariants and contracts preserved? N/A (flaky test setting fix, not a code bug). The pin only changes column compression, which does not affect part/granule structure, ordering, or the teardown path under test.

Session id: cron:clickhouse-worker-slot-1:20260623-222400

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 24, 2026
@murphy-4o murphy-4o self-assigned this Jun 24, 2026
murphy-4o
murphy-4o previously approved these changes Jun 24, 2026
@murphy-4o
murphy-4o dismissed their stale review June 24, 2026 07:15

recheck

@murphy-4o

Copy link
Copy Markdown
Member

@groeneai are you sure it's the root cause of test timeout? zstd can be a little bit slower, but i don't think it's "ZSTD compression/decompression is much slower than LZ4"

@groeneai

Copy link
Copy Markdown
Collaborator Author

You're right, I overstated it. I measured the codec cost on this exact workload (debug build, server default ZSTD(3) vs LZ4 pin, ~1.1 MiB total over 8192 single-row granules):

  • INSERT phase (64 inserts): ZSTD(3) ~2.07s vs LZ4 ~2.01s, delta ~0.06s (and most of the 2s is per-insert client round-trips, not compression).
  • Full scan of all 8192 rows: ZSTD(3) 18ms vs LZ4 17ms, delta ~1ms. The test kills reads after a few rows, so it never even full-scans.

So the codec is not the driver. The real picture from CIDB: on amd_msan, WasmEdge the LZ4-only baseline (5752 runs, no ZSTD anywhere) already sits at p50 227s / max 547s against the 600s cap. The single 600260ms FAIL on this branch was non-reproducible (the report's own rerun with identical randomized settings passed). The runtime is dominated by the 40 sleepEachRow(0.01) kill-mid-read iterations plus polling, not compression, so the test is intrinsically borderline on this build regardless of codec.

I've corrected the PR description. The LZ4 pin is then just a minor variance reduction (and keeps the test on its historical codec, consistent with the 03291/02842/03278/03261 pins on this branch), not a root-cause fix. If you'd rather tackle the borderline runtime directly, I'm happy to drop the pin and instead tag it no-flaky-check or trim the iteration count. Your call.

Session id: cron:clickhouse-worker-slot-2:20260624-074200

@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, retarget this fix to master. You can add no-flaky-check.

The test runtime is dominated by 40 sleepEachRow(0.01) kill-mid-read
iterations (not compression), so on the amd_msan/WasmEdge build it runs
near the 600s per-test cap (CIDB on that lane: p50 ~228s, p90 ~296s,
max OK 547s). The flaky check reruns the test many times in one job,
which reliably tips a borderline run over the cap and produces a 600s
TIMEOUT FAIL. The rerun count does not change the snapshot-teardown
read-pool race the test exercises, so mark it no-flaky-check.

Per a maintainer request, this is retargeted to master (the earlier
codec pin only mattered on the randomize-default-compression-codec
branch, where the server default codec was randomized; on master the
default codec is not randomized, so the pin was a no-op and was dropped
in favor of the no-flaky-check tag).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the groeneai/fix-04039-pin-codec branch from 987582a to f3c5c1f Compare June 24, 2026 17:34
@groeneai
groeneai changed the base branch from randomize-default-compression-codec to master June 24, 2026 17:35
@groeneai groeneai changed the title Pin codec in 04039_merge_tree_snapshot_teardown_race to avoid timeout Exclude 04039_merge_tree_snapshot_teardown_race from the flaky check Jun 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done. Retargeted to master and switched from the LZ4 codec pin to a no-flaky-check tag on 04039_merge_tree_snapshot_teardown_race (the codec pin only mattered on #108093's branch where the default codec is randomized; on master it was a no-op).

The test runtime is dominated by the 40 sleepEachRow(0.01) kill-mid-read iterations, not compression, so it sits near the 600s cap on amd_msan/WasmEdge regardless of codec. no-flaky-check keeps the flaky-check reruns from tipping a borderline run over the cap; the snapshot-teardown race it exercises is unaffected by the rerun count.

Diff is now 1 file, +3/-1 against master.

@alexey-milovidov alexey-milovidov self-assigned this Jun 24, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e9d6e8e]

Summary: ✅


AI Review

Summary

This PR adds no-flaky-check to tests/queries/0_stateless/04039_merge_tree_snapshot_teardown_race.sh so the long snapshot-teardown race test is skipped in --flaky-check jobs while continuing to run in the regular stateless suites. I reviewed the current diff, the runner behavior, and the prior discussion, and I did not find a correctness, coverage-contract, or PR-metadata issue that warrants blocking the change.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 30, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Continuing this PR (it was approved but stuck with no CI checks at all — 0 workflow runs / 0 statuses on the previous head, hence BLOCKED).

  • Merged fresh master into the branch (the prior head was 6 days behind). The merge is clean and the net diff is unchanged — it is still exactly the # Tags: long, no-flaky-check change to 04039_merge_tree_snapshot_teardown_race.sh. The test file is identical on master, so there were no conflicts.
  • The new push re-triggers CI via the synchronize event (the PR workflow is now running on 6f6fb8a), which unblocks the merge gate that had no checks to satisfy.

Verified the fix is mechanically correct: no-flaky-check is recognized in tests/clickhouse-test (if "no-flaky-check" in tags and args.flaky_check: return FailureReason.SKIP), so the test is skipped only in the flaky-check job that reruns it many times and tips a borderline run over the 600s cap on amd_msan, WasmEdge; it still runs normally in regular stateless lanes and continues to exercise the snapshot-teardown read-pool race.

No unresolved review threads. Ready to merge once CI is green.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6f6fb8a

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (amd_tsan) / Hung check failed, possible deadlock found deadlock (chronic: 370 hits / 125 PRs / 76 master in 24h) #101680 / #105905 (ours, open)
Stress test (arm_tsan) / Hung check failed, possible deadlock found deadlock (chronic) #101680 / #105905 (ours, open)
CH Inc sync private sync CH Inc sync (private, not actionable)

The test-only change (# Tags: long, no-flaky-check on 04039) cannot cause a TSan shutdown deadlock; both stress failures are the chronic hung-check family across unrelated PRs and master.

Session id: cron:our-pr-ci-monitor:20260630-083000

@alexey-milovidov

Copy link
Copy Markdown
Member

Merged master into the branch (it was 13 commits behind and red) and pushed 1cdf0efa82b to re-trigger CI. The merge was clean; the diff against master is unchanged — still the +3/-1 no-flaky-check tag on 04039_merge_tree_snapshot_teardown_race.

The only two reds on the previous run (6f6fb8ad) were Stress test (amd_tsan) and Stress test (arm_tsan) both with Hung check failed, possible deadlock found. Both hung stacks are rooted in executeASTFuzzerQueries → InterpreterSelectQueryAnalyzer/executeQueryImpl (AST-fuzzer query execution), with zero frames touching the stateless-test runner or anything this change affects. A pure test-tag change cannot cause an AST-fuzzer hung check, so these are the chronic master-wide hung-check flake tracked in #107941 (still open), not a regression from this PR.

@alexey-milovidov

Copy link
Copy Markdown
Member

Current head 1cdf0efa still has the same two Stress-test reds, but the amd_tsan one now surfaces with a different signature than the run I documented earlier — recording it so it isn't mistaken for a regression:

  • Stress test (arm_tsan) — Hung check failed, possible deadlock found: chronic master-wide flake, tracked in Hung check failed, possible deadlock found #107941.
  • Stress test (amd_tsan) — Logical error: 'std::exception. Code: 1001, type: std::future_error, e.what() = The associated promise has been destructed prior to the associated state becoming ready' (STID 2508-38c6): a shutdown/teardown race in MergeTreeBackgroundExecutor<DynamicRuntimeQueue> → ThreadPoolImpl::worker (the stack has zero stateless-runner frames). This is not new — CIDB shows it firing on 15 distinct days in the last month (06-09 → 06-30) across amd_tsan, arm_tsan, amd_debug, arm_debug, arm_release, arm_msan, and arm_asan_ubsan, i.e. a pre-existing, build-agnostic stress flake that a test-tag-only change cannot introduce.

The diff against master is unchanged — still exactly the # Tags: long, no-flaky-check change (+3/-1) on 04039_merge_tree_snapshot_teardown_race.sh. The branch was merged with master a few hours ago (merge-base today 07:50Z) and has no conflicts, so no re-merge: a re-merge would not clear these flakes. Ready to merge once the Stress lanes are rerun/overridden.

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.70% 85.71% +0.01%
Functions 91.47% 91.47% +0.00%
Branches 78.27% 78.30% +0.04%

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

Newly covered by added/modified tests: 72 line(s), 1 function(s) across 34 file(s) · Details

Top files
  • src/Functions/array/arrayDistance.cpp: 7 line(s)
  • src/AggregateFunctions/AggregateFunctionQuantileInterpolatedWeighted.cpp: 5 line(s)
  • src/Functions/array/arrayNormalizedGini.cpp: 5 line(s)
  • src/Functions/FunctionApplyFilter.cpp: 4 line(s)
  • src/Functions/getServerPort.cpp: 4 line(s)

Full report

@groeneai

groeneai commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 1cdf0ef

CI fully finished (Finish Workflow pass). All reds are chronic trunk Stress-test families, none PR-caused (this PR only excludes 04039 from the flaky check).

Check / test Reason Owner / fixing PR
Stress test (amd_tsan + arm_tsan) / Hung check deadlock (chronic hung-check family) #108212 (ours, merged) / #105905 (ours, merged)
Stress test (amd_tsan) / future_error "promise destructed" (STID 2508-38c6) crash (chronic TaskTracker teardown race: 12 PRs, 0 master/30d) #108730 (ours, open)

Session id: cron:our-pr-ci-monitor:20260703-053000

@alexey-milovidov

Copy link
Copy Markdown
Member

Merged fresh master into the branch (it was ~2 weeks behind and red) and pushed e9d6e8ebe0c to re-trigger CI. The merge is clean — 04039_merge_tree_snapshot_teardown_race.sh is identical on master, so no conflicts, and the net diff against master is unchanged: still exactly the # Tags: long, no-flaky-check change (+3/-1).

The only reds on the previous head (1cdf0efa) were the two Stress test (amd_tsan/arm_tsan) Hung check failed, possible deadlock found failures — the chronic master-wide hung-check flake tracked in #107941, with stacks rooted in executeASTFuzzerQueries → InterpreterSelectQueryAnalyzer (zero frames touching the stateless-test runner). A test-tag-only change cannot cause an AST-fuzzer TSan hung check. No unresolved review threads; approved. Ready to merge once the Stress lanes are rerun/green.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 14, 2026
Merged via the queue into ClickHouse:master with commit 0a0cd9d Jul 14, 2026
176 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 14, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-pin-codec

Exclude 04039_merge_tree_snapshot_teardown_race from the flaky check
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.

4 participants