Skip to content

Cherry pick #116591 to 26.7: CI: fix integration test session timeouts (shard balance and batch count) - #119520

Merged
PedroTadim merged 9 commits into
backport/26.7/116591from
cherrypick/26.7/116591
Sep 12, 2026
Merged

PedroTadim merged 9 commits into
backport/26.7/116591from
cherrypick/26.7/116591

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Original pull-request #116591

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 9 commits August 26, 2026 20:41
`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]>
`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).
…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`.
CI: fix integration test session timeouts (shard balance and batch count)
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Sep 11, 2026
@PedroTadim
PedroTadim merged commit f231127 into backport/26.7/116591 Sep 12, 2026
190 of 191 checks passed
@PedroTadim
PedroTadim deleted the cherrypick/26.7/116591 branch September 12, 2026 16:07

This branch was successfully deployed

1 active deployment
staging - docs — 90e36d77 Deployed Sep 3, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants