Skip to content

Run heavy delta modules sequentially in the integration flaky check - #107049

Merged
maxknv merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-test-storage-delta-flaky-oom-concurrency
Jun 27, 2026
Merged

maxknv merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-test-storage-delta-flaky-oom-concurrency

Conversation

@groeneai

@groeneai groeneai commented Jun 10, 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

The flaky/targeted integration checks schedule the parallel bucket with -n {workers} --dist=each, so every xdist worker runs every parallel module concurrently. On AMD_MEDIUM (16 cpu, 61 GiB) workers = min(16//5, 61//11) = 3.

test_storage_delta/test.py starts a 5-node ClickHouse cluster plus a Spark JVM in its module-scoped fixture. Three concurrent copies meant ~15 ASan servers + 3 JVMs on a 61 GiB host and a kernel OOM that surfaced as an in-test hang (e.g. run 27175604347/job 80226138143 hung at test_checkpoint[1-s3] and was SIGTERMed by the praktika timeout). Reducing the per-JVM heap (8g -> 2g, #106698) helped but did not remove the concurrency driver.

This moves the heavy delta modules (test_storage_delta/test.py, test_storage_delta/test_cdf.py, test_storage_delta_disks/test.py) out of the --dist=each parallel bucket into the looped sequential bucket (-n 1, repeated >=3x) for the flaky/targeted path only. At most one delta cluster runs at a time, so the OOM driver is removed while the flakiness signal is preserved. Normal master/PR runs use --dist=loadfile (one file -> one worker -> one cluster) and never take this path, so they are unaffected.

The move is done by a small force_heavy_modules_sequential helper in ci/jobs/scripts/integration_tests_configs.py, gated on is_flaky_check or is_targeted_check in ci/jobs/integration_test_job.py. A regression test in ci/tests/test_force_heavy_modules_sequential.py pins the behavior.

Version info

  • Merged into: 26.7.1.152 (included in 26.7 and later)

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. The failure is a CI scheduling decision, reproduced deterministically by replaying the real get_optimal_test_batch split + the AMD_MEDIUM worker formula workers = min(16//5, 61//11) = 3: the three heavy delta modules land in the --dist=each parallel bucket, so all 3 workers start their 5-node cluster + Spark JVM at once (~15 ASan servers + 3 JVMs on 61 GiB -> OOM/hang, as seen in run 27175604347/job 80226138143 hanging at test_checkpoint[1-s3]). The regression test ci/tests/test_force_heavy_modules_sequential.py encodes this.
b Root cause explained? The flaky/targeted parallel bucket runs -n {workers} --dist=each (every xdist worker runs every parallel module concurrently). test_storage_delta/test.py's module fixture starts 5 ClickHouse instances + minio + azurite + a Spark JVM; with workers=3 that is 3 concurrent copies on a 61 GiB runner, exhausting memory. The sequential bucket instead runs -n 1 looped max(3, workers) times, i.e. one cluster at a time. Per-JVM heap was already cut 8g->2g in #106698, which was necessary but not sufficient because the driver is concurrency x cluster-size, not per-JVM heap.
c Fix matches root cause? Yes. The fix directly removes the concurrency: it moves the heavy delta modules from the concurrent --dist=each bucket to the looped -n 1 sequential bucket, so at most one delta cluster exists at any moment. It targets the mechanism from (b), not a symptom — no heap shrinking, no data reduction, no assertion widening.
d Test intent preserved / new tests added? Yes. The modules still run under the flaky check, repeated >=3x sequentially, so the flakiness signal is preserved (just serialized, not skipped or weakened). New regression test ci/tests/test_force_heavy_modules_sequential.py (6 cases) pins: heavy modules move to sequential, light modules stay parallel, order/existing-sequential preserved, non-heavy delta modules untouched, idempotence, and a guard that the prefixes match real on-disk module paths.
e Both directions demonstrated? Yes. With the helper absent, the heavy modules stay in the --dist=each bucket (OOM driver present, EXIT=1 in the replay). With the helper applied, they move to the looped sequential bucket (EXIT=0). The 6 regression tests all pass (run via direct import; pytest unavailable locally).
f Fix is general, not a narrow patch? The same OOM pattern applies to any heavy multi-node + Spark module under --dist=each, so the fix is an extensible policy list FLAKY_FORCE_SEQUENTIAL_PREFIXES covering all three heavy delta modules (test.py, test_cdf.py, test_storage_delta_disks/test.py), not a one-module patch. Scoped to the flaky/targeted path only (is_flaky_check or is_targeted_check); normal --dist=loadfile runs already use one cluster per file and are untouched, so no regression to ~140 normal integration jobs. Future heavy modules can be added to the one list.

Session id: cron:clickhouse-worker-slot-0:20260610-173000

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus — could you review this? CI-infra fix: route the heavy test_storage_delta modules to the looped sequential phase under the flaky/targeted integration check's --dist=each scheduling, so they no longer start one 5-node cluster + Spark JVM per xdist worker (the AMD_MEDIUM OOM-hang). Normal --dist=loadfile runs are unaffected.

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

clickhouse-gh Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e2a8a6f]

Summary: ✅


AI Review

Summary

This PR adds a dist_each_sequential scheduling flag for integration suites that should stay parallel in normal --dist=loadfile jobs but must be serialized in flaky/targeted --dist=each jobs. The implementation routes the flagged modules into the existing looped sequential phase and adds focused regression coverage for the delta and test_dns_cache cases. I did not find any material correctness or CI-scheduler issues that need inline comments.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI fully finished (Finish Workflow passed) with no test failures. This PR (run heavy delta modules sequentially in the integration flaky check) is CI-clean. Ready for review.

@leshikus
leshikus self-requested a review June 11, 2026 07:26

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • The flaky check itself is skipped on this PR, you better check your changes before committing them
  • A separate, larger-memory job could run the 3 passes concurrently and off the critical path — clawing back that ~40 min.
  • Parallel / sequential scheduling is guided by TEST_CONFIGS from ci/jobs/scripts/integration_tests_configs.py, why not to set a test config instead of hardcoding the scheduling?

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jun 11, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

@leshikus thanks for the review. Addressing all three points.

1. Flaky check skipped on this PR. You are right that the Integration tests (amd_asan_ubsan, flaky) job did not run here, and it cannot: filter_job.py gates it on has_new_integration_tests(changed_files) (line 232-235), which is true only when the PR adds or changes a tests/integration/test_*/test*.py module. This PR only touches ci/ scheduling code, so the flaky check is correctly skipped (the check exists to stress new/changed integration tests, not to re-run the whole suite, and adding the ci-integration-flaky label does not bypass that gate). So I verified the change by replaying the real CI split locally over all 959 integration modules at the AMD_MEDIUM worker count (workers = min(16//5, 61//11) = 3):

  • Normal --dist=loadfile run (get_optimal_test_batch only): the 3 heavy delta modules stay in the parallel bucket, sequential bucket has none of them. No regression to the ~140 normal jobs.
  • Flaky/targeted --dist=each run: without the change the 3 modules are in the parallel bucket (3 concurrent 5-node clusters + Spark JVMs = the OOM driver); with the change they move to the looped sequential bucket (-n 1, repeated >=3x), at most one cluster at a time. No module lost or duplicated.

Both directions plus the normal-run invariant are pinned in ci/tests/test_force_heavy_modules_sequential.py (7 cases, all pass).

3. TEST_CONFIGS vs hardcoded scheduling. Good call, done in 9b6205f. The reason I did not just set is_sequential=True is that is_sequential makes a module sequential in every integration job, including all ~140 normal --dist=loadfile runs, where the delta modules are fine (one cluster per file). The OOM is specific to --dist=each. So I added a second TEST_CONFIGS flag dist_each_sequential that means "sequential only under the flaky/targeted --dist=each schedule, parallel otherwise". The three delta modules are now plain TC(..., dist_each_sequential=True) entries in TEST_CONFIGS, the policy lives in the one place you pointed at, and force_heavy_modules_sequential just reads the flag. A regression test asserts the two flags never coincide for these modules so nobody accidentally serializes them everywhere.

2. Larger-memory job running the 3 passes concurrently. Real idea and it would claw back the ~40 min, but it is a bigger infra change (a new larger-memory runner pool plus workflow wiring, and the flaky check would then depend on that pool's availability). This PR is the minimal, reversible fix that removes the OOM driver now and is scoped to the --dist=each path only, so I would prefer to land it first and treat the dedicated bigger-memory job as a separate follow-up rather than couple the two. Happy to open a follow-up issue for it if you agree.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (commit 9b6205f)

# Question Answer
a Deterministic repro? Yes. CI scheduling decision, reproduced deterministically by replaying the real get_optimal_test_batch split over all 959 integration modules at the AMD_MEDIUM worker count (workers = min(16//5, 61//11) = 3). Without the fix the three heavy delta modules land in the --dist=each parallel bucket (3 concurrent 5-node clusters + Spark JVMs = OOM driver); with it they move to the looped sequential bucket.
b Root cause explained? The flaky/targeted parallel bucket runs -n {workers} --dist=each (every xdist worker runs every parallel module concurrently). test_storage_delta/test.py etc. start a Spark JVM + 5-node ClickHouse cluster per module fixture; with workers=3 that is 3 concurrent copies on a 61 GiB runner, exhausting memory. Driver is concurrency x cluster-size, not per-JVM heap (already cut 8g->2g in #106698).
c Fix matches root cause? Yes. Removes the concurrency: heavy modules move from the concurrent --dist=each bucket to the looped -n 1 sequential bucket, so at most one delta cluster exists at any moment. No heap shrinking, no data reduction, no assertion widening. This revision expresses that policy via a new TEST_CONFIGS flag dist_each_sequential (the existing single source of truth for scheduling) instead of a standalone prefix list.
d Test intent preserved / new tests added? Yes. Modules still run under the flaky check, repeated >=3x sequentially, so the flakiness signal is preserved (serialized, not skipped or weakened). Regression test ci/tests/test_force_heavy_modules_sequential.py now has 7 cases including a new one asserting dist_each_sequential modules are NOT also is_sequential (so they stay parallel in the ~140 normal --dist=loadfile jobs).
e Both directions demonstrated? Yes. Local replay over the real 959-module split: WITHOUT force_heavy_modules_sequential the heavy modules stay in the --dist=each parallel bucket; WITH it they move to sequential (none left in parallel, none lost/duplicated). Normal-run invariant also asserted: under --dist=loadfile the heavy modules stay parallel. 7/7 regression tests pass.
f Fix is general, not a narrow patch? The policy is an extensible TEST_CONFIGS flag covering all three heavy delta modules; future heavy multi-node + Spark modules are added by setting dist_each_sequential=True on their TC entry. Scoped to the flaky/targeted --dist=each path only; normal --dist=loadfile runs (one cluster/file) are untouched, so no regression to the ~140 normal integration jobs.

Session id: cron:clickhouse-worker-slot-4:20260611-081600

@maxknv

maxknv commented Jun 11, 2026 •

Copy link
Copy Markdown
Member

@groeneai , please add a minor change in some of the py test files (grammar fix or formatting) to trigger flaky / targeted job

@fm4v, can you review it, please?

@groeneai

Copy link
Copy Markdown
Collaborator Author

@maxknv done in 0bcbde5. I fixed a comment typo (reproted -> reported) in tests/integration/test_storage_delta/test.py.

That touches a tests/integration/test_*/test*.py file, so has_new_integration_tests (filter_job.py) is now true and the Integration flaky/targeted check runs instead of being "Skipped, no integration tests updates". Because test_storage_delta/test.py is a changed module, it also lands in the flaky check's --dist=each parallel set and is then routed to the looped sequential phase by the new dist_each_sequential policy, so the scheduling change is exercised on real CI now, not just the local replay. The change is a no-op for test behavior, so no new validation gate beyond the one posted for 9b6205f.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI summary for HEAD 0bcbde5f2319 (re-validated after the flaky-check-trigger typo commit): all praktika gating checks green, Finish Workflow + Mergeable Check passed. Only non-green context is CH Inc sync (external ClickHouse-Inc mirror, always pending for fork PRs, non-gating). No PR-caused failures. Ready for review.

Session: cron:our-pr-ci-monitor:20260612-033000

groeneai and others added 3 commits June 17, 2026 07:18
The flaky/targeted integration checks schedule the parallel bucket with
`-n {workers} --dist=each`, so every xdist worker runs every parallel module
at once. On AMD_MEDIUM (16 cpu, 61 GiB) workers = min(16//5, 61//11) = 3.

test_storage_delta/test.py starts a 5-node ClickHouse cluster plus a Spark JVM
in its module-scoped fixture; three concurrent copies meant ~15 ASan servers +
3 JVMs on 61 GiB and a kernel OOM that surfaced as an in-test hang. Reducing the
per-JVM heap (8g -> 2g, ClickHouse#106698) helped but did not remove the concurrency
driver.

Move the heavy delta modules (test_storage_delta/test.py,
test_storage_delta/test_cdf.py, test_storage_delta_disks/test.py) out of the
`--dist=each` parallel bucket into the looped sequential bucket (`-n 1`, repeated
>=3x) for the flaky/targeted path only. At most one delta cluster runs at a time,
so the OOM driver is gone while the flakiness signal is preserved. Normal runs
use `--dist=loadfile` (one file -> one worker -> one cluster) and never call this,
so they are unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Address review feedback: instead of a standalone prefix list, mark the
heavy delta modules with a new TEST_CONFIGS flag dist_each_sequential.
TEST_CONFIGS is the existing single source of truth for parallel vs
sequential integration scheduling, so the policy now lives in one place.

The flag is distinct from is_sequential on purpose. is_sequential makes a
module sequential in every integration job (all ~140 normal --dist=loadfile
jobs included), where the delta modules run fine with one cluster per file.
The OOM only happens under the flaky/targeted --dist=each schedule, where
each xdist worker starts its own 5-node cluster plus Spark JVM. So
dist_each_sequential moves the module to the looped sequential bucket only
on that path and leaves normal runs untouched. force_heavy_modules_sequential
now derives its prefix list from the flag and a regression test asserts the
two flags never coincide for these modules.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The integration flaky/targeted check is skipped on a ci/-only PR because
has_new_integration_tests is false, so the new dist_each_sequential
scheduling change went unverified by CI. Touch a heavy delta module with a
comment grammar fix (reproted -> reported) so the flaky/targeted check runs
and exercises the sequential path on test_storage_delta itself.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the fix-test-storage-delta-flaky-oom-concurrency branch from 0bcbde5 to b0f0378 Compare June 17, 2026 07:22
@groeneai

Copy link
Copy Markdown
Collaborator Author

Rebased onto current master to resolve a conflict in ci/jobs/scripts/integration_tests_configs.py.

The conflict was additive: master added two fixed-port azure entries at the same TEST_CONFIGS insertion point this PR uses.

  • master: test_storage_delta/test_azure_cluster.py and test_storage_iceberg_interoperability_azure/, both is_sequential=True (azurite binds fixed host port 10000, so concurrent --dist=each workers collide).
  • this PR: the three heavy delta modules with dist_each_sequential=True.

Resolution keeps both sets. The prefixes are distinct and the rationales do not overlap (port-bind collision vs concurrent-cluster OOM), so no logic changed. The dist_each_sequential scheduling and its gating in integration_test_job.py are byte-for-byte unchanged; the 7 regression cases in ci/tests/test_force_heavy_modules_sequential.py still pass (including the prefix-vs-real-path guard, which now also covers master's two azure entries).

New HEAD b0f03788afd.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - b0f0378

CI fully finished on the rebased HEAD b0f03788afda (the 2026-06-17 master-merge that resolved the integration_tests_configs.py conflict, plus the flaky-check-trigger typo commit). All gating checks green, zero test failures across the full run (0 FAIL/ERROR, 88130 OK).

Per the finish-ledger rule every failure must link a fixing PR; there are no failures to link. The only non-green check is CH Inc sync (private ClickHouse Inc mirror, non-gating for fork PRs).

Session id: cron:our-pr-ci-monitor:20260624-130000

test_dns_cache pins fixed IPv6/IPv4 addresses on the single shared
docker_compose_net.yml subnet (10.0.0.0/12 + 2001:3984:3989::/64), so
ClickHouseCluster.start() holds the global /tmp/docker_net.lock for the
whole cluster lifetime. Under the flaky/targeted --dist=each schedule every
xdist worker starts its own copy at once; they serialize on that lock and
exceed the 10-minute acquire budget, so cluster.start() raises in the
cluster_start fixture and all test_dns_cache cases fail before their bodies
run (0 failures on master).

This is the same --dist=each self-contention the heavy delta modules already
carry dist_each_sequential=True for; only the contended resource differs
(global Docker-network lock vs host memory). Set the same flag on
test_dns_cache so it runs on the looped sequential phase under --dist=each
(one cluster at a time, lock never contended) while staying parallel in the
~140 normal --dist=loadfile jobs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
auto-merge was automatically disabled June 26, 2026 21:59

Head branch was pushed to by a user without write access

@maxknv
maxknv enabled auto-merge June 26, 2026 22:12
@clickhouse-gh

clickhouse-gh Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

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

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

Newly covered by added/modified tests: 321 line(s), 7 function(s) across 115 file(s) · Details

Top files
  • src/Backups/BackupEntriesCollector.cpp: 23 line(s), 2 function(s)
  • src/Databases/DatabaseReplicated.cpp: 17 line(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 14 line(s)
  • src/Databases/DatabaseReplicatedWorker.cpp: 10 line(s)
  • src/Storages/MergeTree/LeaderElection.h: 9 line(s)

Full report

@maxknv
maxknv added this pull request to the merge queue Jun 27, 2026
Merged via the queue into ClickHouse:master with commit 59e26b4 Jun 27, 2026
169 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 Jun 27, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…elta-flaky-oom-concurrency

Run heavy delta modules sequentially in the integration 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 manual approve Manual approve required to run CI 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.

6 participants