Repository navigation
CI: fix integration test session timeouts (shard balance and batch count) - #116591
Conversation
`get_optimal_test_batch` bin-packs integration test shards by the estimates in `RAW_TEST_DURATIONS`. A module missing from that table weighs nothing and is only round-robin distributed, so the packer cannot see it. The table was last refreshed on 2026-06-25, and its `HAVING dur > 60000` floor left only 297 of the 1104 test modules with an entry, hiding 31% of the measured wall-clock mass from the packer. The modelled part came out balanced to within 230 seconds per shard, while the unmodelled part varied by 2576 seconds. On https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=887b93e16db98a72906f035e47af9b2ffbf58aa2&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%203%2F6%29 that was enough for batch 3 to hit the two-hour pytest `--session-timeout` with 50 of its 998 tests never started, while batch 6 finished 25 minutes early. Four of the six batches of this job have timed out this way since 2026-08-16. Refresh the table and lower the floor to 20000ms, taking coverage from 69% to 96% of the measured mass. Scored against the last 20 days of CIDB durations, the worst shard drops from 94% to 86% of the session timeout, and the spread between shards from 1064 to 101 seconds. Only the table changes - the packing algorithm is left alone. Charging unmodelled modules a flat estimate instead of round-robin distributing them was measured too, and it is a wash at best: with a well-covered table the two are within noise of each other, and with a stale one the flat estimate is worse, because it prices a heavy new module the same as a trivial one. Add `ci/tests/test_integration_batch_balance.py` to keep the coverage from rotting back, along with the packer invariants it relies on. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The docstring referenced a placeholder number rather than the pull request that carries the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [2c10dbc] Summary: ✅ AI ReviewSummaryThis PR now only changes the release-branch Findings
Tests
Final Verdict
|
`integration_test_asan_master_jobs` - used, despite the name, only by
`release_branches.py` - ran the whole integration suite over four batches. The suite is
about 110000 test-seconds, and four batches of three xdist workers come to roughly 9400
seconds per batch against a two-hour pytest `--session-timeout`, so no amount of
balancing fits. All four batches have been sitting right at the timeout and about half
of all release-branch runs of this job ended in `session-timeout`, dropping the tests
that had not started yet:
shard test-seconds (p50, truncated by the timeout) est. wall-clock
1/4 21635 7212 s
2/4 21642 7214 s
3/4 21635 7212 s
4/4 20957 6986 s
Six batches bring that to about 6300 seconds each. Only `ReleaseBranchCI` gains jobs;
`MasterCI` and `PR` never referenced this job set.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The guard only proved that the checked-in estimates are internally consistent: `test_duration_table_covers_most_test_modules` counted entries, and `test_shards_are_balanced` weighed the shards with the very table that produced the packing, so every unknown module weighed 0 on both sides. Dropping a heavy prefix out of `TEST_DURATIONS` left both assertions green while concentrating enough real work on one shard to blow the pytest `--session-timeout` - exactly the failure this pull request is about. Check in `ci/tests/data/integration_test_durations_sample.tsv`, the unfloored CIDB sample of every module's measured duration, and score the assertions against it instead: coverage is now the share of measured wall-clock mass the packer can see (67% on the stale table, 95% on the refreshed one, floor at 85%), and balance is the spread of the shards' measured wall-clock under the packing the table produces (1.08 stale, 1.03 refreshed, limit 1.06). `test_hidden_mass_unbalances_the_shards` keeps that scoring honest: it hides the heaviest prefix from the packer and asserts the balance assertion fires (it comes out at 1.24, with the worst shard at 7330s against the 7200s session timeout).
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/PRs/116591/aea33af00d18cd5e20fdd0b01cde108afed8f437/integration_tests_amd_asan_ubsan_db_disk_old_analyzer_6_6/job.log and provide a fix in a separate PR. If the fix is already in progress, link it here. It is not a shard-balance failure, so it is unrelated to this pull request. The job hung: Two things stand out:
|
|
Investigated. It is not All three workers stopped within 33 seconds of each other, each in the middle of a different file, with 466 of the run's 949 items still to go:
Three unrelated files going quiet at one instant is a host stall, not a Kafka defect. One correction on the timers. The containment and reporting half is in progress in #112984, where you asked me to fold the hard-timeout diagnostics on 2026-08-17: it bounds the nested containers by the job's memory limit, classifies the hard backstop apart from a graceful session timeout, scans What none of them add is the outer bound: nothing ends the run on worker inactivity, so this job burned 1h48m of silence before the 7800 s backstop reached it. I will send that as a separate PR and link it here. |
|
Follow-up with the measurement I was missing, which changes my conclusion. That job's own result carries a That signature discriminates cleanly. Over 142 recent PR reports, 4360 integration job nodes that actually ran: 11 carry So this is not a class that wants a new timer. It is nested-container memory budgeting, which is what #112984 does by deriving the worker count from the container budget instead of from host memory. It is open with your review requested since 2026-08-17. I had said I would send an outer inactivity bound as a separate PR. I would rather not: on this evidence it would mask this class instead of fixing it, and it would be my fifth open PR in that seam. If you want it anyway as defence in depth for stalls that are not memory, tell me and I will send it; the design and the thresholds are measured and ready. |
|
Correcting the measurement I posted above, since you still have a decision open on it. I claimed sustained memory stall was the only thing separating these hangs from 4355 healthy nodes. That comparison was confounded by load: almost all of those healthy nodes were near-idle runs. On What the wedges do show is the inner dockerd ceasing to be scheduled: on #113107 its log has a single 130 minute gap with 690 lines after it, and it then reports 12 containers That removes the reason I gave for declining the inactivity bound. It would not be masking a memory bug, and it would have bounded the 4.5 hours these runs spend dead after the daemon stalls, though it still would not prevent the stall. The design and thresholds remain ready if you want it. |
…session timeout `test_shards_are_balanced` only checked the *spread* between shards, so a suite that grows uniformly keeps the shards evenly matched while walking all of them off the end of the two-hour `--session-timeout` - exactly the failure the `4 -> 6` batch-count change fixed, with no guard against its return. `test_shards_fit_the_session_timeout` now bounds each shard against the budget it actually runs under. The parallel and sequential buckets are two separate pytest runs with two separate timeouts (`session_timeout_parallel` and `session_timeout_sequential` in `ci/jobs/integration_test_job.py`), so `_shard_bucket_walls` keeps them apart and each is scored against its own. A shard may take at most 90% of its budget: the modelled wall counts measured test durations only, not cluster setup or image pulls, and the remaining 720s of the parallel budget is the slack for that. On the measured sample the heaviest parallel bucket is 6098s against the 6480s bound. `test_too_few_shards_do_not_fit_the_session_timeout` keeps that bound honest the way `test_hidden_mass_unbalances_the_shards` keeps the balance assertion honest: packed into the four batches this job used to run with, the same sample puts 9147s on the worst shard, well past the 7200s timeout.
…d-balance Conflict resolution: master has since refreshed `RAW_TEST_DURATIONS` itself with a 1000ms floor, which is broader than the 20000ms floor this branch lowered it to, so `ci/jobs/scripts/integration_tests_configs.py` is taken from master wholesale and this branch no longer touches it. Scored against the checked-in sample, master's table models 99% of the measured wall-clock mass and packs six shards to an imbalance of 1.03, so the guard assertions hold against it unchanged. `.github/workflows/release_branches.yml` is generated, so it was taken from master and regenerated with `python3 -m praktika yaml`; the only difference from master is the four-to-six batch split this branch makes in `integration_test_asan_master_jobs`.
This branch predates the asan/ubsan build merge and praktika's `--timestamp` flag, so none of the incoming workflow text applies verbatim: its job family is `integration_tests_amd_asan_db_disk_*` depending on `build_amd_asan`. The 4 -> 6 batch change is re-expressed in those names over this branch's own generated blocks, keeping its pipefail/tee Run step, with the two new batches cloned from its 4/6 block. The job names match `job_configs.py` after the merge, which sets `amd_asan` with six batches. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Conflict was the generated `finish_workflow` block. Kept this branch's `runs-on` and `needs`, swapping only the db-disk batch entries, so the runner label and job set stay the ones this branch actually builds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Conflict was the generated `finish_workflow` block. Kept this branch's `runs-on` and `needs`, swapping only the db-disk batch entries, so the runner label and job set stay the ones this branch actually builds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Conflict was the generated `finish_workflow` block. Kept this branch's `runs-on` and `needs`, swapping only the db-disk batch entries, so the runner label and job set stay the ones this branch actually builds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…shard balance and batch count)
…shard balance and batch count)
…shard balance and batch count)
…shard balance and batch count)
`Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6)` reported `Timeout` on master with `xdist.dsession.Interrupted: session-timeout: 7200.0 sec exceeded` after `974 passed, 10 skipped ... in 7360.29s`. Nothing failed and nothing hung - the longest quiet gap in the whole run was 136 s - the batch simply held more work than the two-hour pytest `--session-timeout` allows, and was cut off with 20 of its 1004 modules still to go. This is chronic rather than a one-off. Over the last three weeks the six old-analyzer batches reported `Timeout` 133 times between them, on every one of the six. The job is required on every pull request, on master and on backport branches, so each occurrence is a red required check on an unrelated change. The cause is capacity, not balance. The integration suite measures about 112000 test-seconds; six batches of three xdist workers can absorb at most 129600, so the packing runs at 86% of the budget on average and the heaviest shard lands at 119.7 of the 120 available minutes. Scoring `get_optimal_test_batch` over the 1139 modules actually in `tests/integration/`, weighted by per-module `sum(test_duration_ms)` measured on the failing commit itself, reproduces the failure exactly: batch 5 of 6 - the batch that timed out - is the heaviest, at 100% of budget. At eight batches the heaviest shard is 82 minutes, 68% of the budget, and the measured spread across shards narrows from 1.24 to 1.09. Batches are the right lever rather than a longer timeout. Aggregate compute is unchanged, because the work is the same and only the parallelism differs, so the only cost is one more per-batch setup (about 3 minutes) - and the job returns its answer 25% sooner than it does today. Both ASan flavors move together. `integration_test_asan_master_jobs` (`amd_asan_ubsan, db disk`, release branches) runs the same suite with the same worker count against the same budget and sits at the same 96-103 minutes per shard, so the measurement that rules out six for one rules it out for the other; it has simply had far fewer runs in which to show it since ClickHouse#116591 took it from four to six. The shared count now lives in `ASAN_IT_NUM_BATCHES` so the two cannot drift apart. `CORE_BLOCKING_JOB_NAMES` selects these jobs by substring, so the blocking gate picks up all eight batches with no change. While measuring this: `TEST_DURATIONS` in `ci/jobs/scripts/integration_tests_configs.py` sums to about 97000 test-seconds against a measured 112000, so the packer reports every shard as evenly packed (printing weights of `[5384, 5384, 5384, 5384, 5384, 5383]` for a run whose real shards ranged over 97 to 120 minutes). Refreshing that table is separate periodic maintenance - it is documented as such, and it repacks every integration flavor at once - so it is left for its own change. Eight batches hold with the table as it is. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=417aa9966eed1467f418da9b4deae15ef020c5f3&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%205%2F6%29 Related: ClickHouse#116591 Related: ClickHouse#115963 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Backport #116591 to 26.3: CI: fix integration test session timeouts (shard balance and batch count)
Backport #116591 to 26.6: CI: fix integration test session timeouts (shard balance and batch count)
Backport #116591 to 26.7: CI: fix integration test session timeouts (shard balance and batch count)
Backport #116591 to 26.8: CI: fix integration test session timeouts (shard balance and batch count)
Two integration test jobs were running out of the two-hour pytest
--session-timeout, for two different reasons.Shard balance: the duration table had gone stale
Shards are bin-packed by
get_optimal_test_batchusing the estimates inRAW_TEST_DURATIONS. A module missing from that table weighs nothing and is only round-robin distributed, so the packer cannot see it.The table was last refreshed on 2026-06-25, and its
HAVING dur > 60000floor left only 297 of the 1104 test modules with an entry, hiding 31% of the measured wall-clock mass. The modelled part of each shard came out balanced to within 230 seconds; the unmodelled part varied by 2576 seconds.On the report below that was enough for batch 3 to hit the session timeout with 50 of its 998 tests never started, while batch 6 finished 25 minutes early:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=887b93e16db98a72906f035e47af9b2ffbf58aa2&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%203%2F6%29
Four of the six batches of this job have timed out this way since 2026-08-16.
Master has since refreshed
RAW_TEST_DURATIONSitself, with a1000 msfloor — broader than the20000 msthis PR was lowering it to — so that half of the change is now redundant and this branch no longer touchesci/jobs/scripts/integration_tests_configs.pyat all. What remains from it is the regression guard, which is what keeps the table from going stale again.ci/tests/test_integration_batch_balance.pyscores the table againstci/tests/data/integration_test_durations_sample.tsv, an unfloored CIDB sample of every module's measured duration, rather than against the table itself — otherwise a module the packer cannot see weighs zero on both sides of the assertion. Coverage is the share of measured wall-clock mass the packer can see (67% when the shard first timed out, 99% with master's current table, floor at 85%), and balance is the spread of the shards' measured wall-clock under the packing the table produces (1.08 then, 1.03 now, limit 1.06).test_hidden_mass_unbalances_the_shardschecks the scoring has teeth: hiding the heaviest prefix from the packer must trip the balance assertion, and it does.Capacity: four batches cannot fit the suite
integration_test_asan_master_jobs— used, despite the name, only byrelease_branches.py— split the whole suite four ways. At about 110000 test-seconds total, four batches of three xdist workers come to roughly 9400 seconds each, so no amount of balancing fits inside two hours. All four batches sat right at the timeout, and about half of all release-branch runs of this job ended insession-timeout:Six batches bring that to about 6300 seconds each. Only
ReleaseBranchCIgains jobs;MasterCIandPRnever referenced this job set — and since release branches carry their own copy of both files, 26.4 through 26.8 need a backport to benefit.Balance alone does not guard this half: a suite that grows uniformly keeps the shards evenly matched while walking all of them off the end of the budget. So
test_shards_fit_the_session_timeoutalso bounds each shard's measured wall against the budget it is run under. The parallel and sequential buckets are two separate pytest runs with two separate timeouts (session_timeout_parallelandsession_timeout_sequentialinci/jobs/integration_test_job.py), so each is scored against its own. A shard may take at most 90% of its budget: the modelled wall counts measured test durations only, not cluster setup or image pulls, and the remaining720 sof the parallel budget is the slack for that — and the alarm to raise the batch count rather than raise the bound. On the sample the heaviest parallel bucket is6127 sagainst the6480 sbound.test_too_few_shards_do_not_fit_the_session_timeoutkeeps that bound honest the way the hidden-mass test keeps the balance assertion honest: at four batches the same sample puts9301 son the worst shard.I found no existing issue tracking either failure.
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/116591]
Version info
26.9.1.580(included in26.9and later)26.8.3.99,26.7.7.88,26.6.5.116,26.3.33.63