Skip to content

CI: stateless tests time out due to network latency between our runners and the S3 test-data bucket #2227

Open

Description

@CarlosFelipeOR

Type of problem

CI infrastructure — not a product bug, and not slow machines.

Summary

Stateless tests that read test.hits get killed by the 600s per-test timeout on our CI.
The same tests, on the same build type, never come close to that limit upstream.

240 timeout deaths in 90 days, concentrated in three builds:

build timeout deaths runs
amd_debug 181 104,932
arm_binary 44 67,596
amd_binary 15 2,522

Sanitizer and coverage builds are essentially unaffected (amd_msan, amd_ubsan,
arm_asan_ubsan, both coverage builds: 0).

Root cause

test.hits is not on local disk. tests/docker_scripts/create.sql:142-144 puts it on a
cache disk wrapping a web disk pointing at S3 in us-east-1:

SETTINGS
    table_disk = 1,
    disk = disk(type = cache, path = 'filesystem_caches/stateful/', max_size = '4G',
    disk = disk(type = web, endpoint = 'https://clickhouse-datasets-web.s3.us-east-1.amazonaws.com/...'));

That 4 GB cache layer exists precisely so the remote reads are paid once. But
tests/clickhouse-test randomizes the setting that disables it, 50/50:

"enable_filesystem_cache": lambda: random.randint(0, 1),

When the coin lands on 0, every column read becomes an HTTP request to us-east-1. Our
runners pay ~207ms just to open each connection to that bucket (measured below); upstream's
test durations show they do not.

Both files are byte-identical to upstream. Same code, same dataset, same randomization —
the only variable is where the runner sits.

Evidence

1. Controlled experiment — the setting isolated

Same table, same query, warm cache present, alternating only enable_filesystem_cache.
Identical result hash in every run:

test query cache=1 cache=0 ratio
00071_merge_tree_optimize_aio (6 columns) 1.25s / 1.22s 60.0s / 53.6s 46x
00154_avro (131 columns) 0.86s / 0.82s 28.1s / 26.4s 33x
03595_extract_url_parameters (1 column) 0.82s / 0.81s 3.04s / 2.82s 3.6x

The multiplier scales with how many files the query opens, not how much data it reads.

2. The cost is connection setup, not bandwidth

Measured against the bucket endpoint:

new connection:      connect 140ms -> TLS 285ms -> first byte 445ms
20 requests reusing a single connection:  0.159s total  =  8ms each

55x, and ~300ms of the 445ms is pure TCP+TLS handshake. RTT is ~137ms.

Connections are barely reused. ProfileEvents from one query with the cache off:

ReadWriteBufferFromHTTPRequestsSent:  280
ReadWriteBufferFromHTTPBytes:         13,265,792
DiskConnectionsCreated:               139
DiskConnectionsReused:                141

139 handshakes for 280 requests. On CI runners the same counters give ~207ms per
connection
(35.9s across 173 connections).

With the cache on: 306 cache hits, 9.9 MB from local disk, 4.6ms, zero HTTP.

3. Our machines are not slower — upstream comparison

Same build (amd_debug, parallel), 90 days:

test upstream p50 upstream max our p50 our max
00071_merge_tree_optimize_aio 3.08s 56.4s 2.00s 810.3s
03595_extract_url_parameters 2.67s 26.9s 2.24s 860.9s
00088_global_in_one_shard_and_rows_before_limit 0.7s 13.9s 0.7s 582.4s
00174_distinct_in_order 1.3s 25.3s 1.5s 553.0s

Our median matches or beats upstream's. CPU is fine — one failing query used 1.7s of CPU
across 395s of wall clock, 99.6% blocked on I/O. What differs is the tail: upstream's
worst case across ~27,000 runs each is 14–56s; ours reaches 810–860s.

Second failure mode, not fixed by the timeout

The same latency also trips ClickHouse's own execution-speed guard. From
tests/config/users.d/limits.yaml:

timeout_before_checking_execution_speed: 300
max_estimated_execution_time: 900

After 300s the server estimates total runtime; if the estimate exceeds 900s it aborts the
query with TOO_SLOW (error 160) — well before any test timeout. Three stateful tests
failed this way in a single recent run, at 317s, 391s and 480s.

The file's own comment says these limits are set high "so it will not limit anything". On our
infra they do.

What we did — workaround only

PR #2223 raises the per-test timeout from 600s to 1200s for amd_debug, arm_binary and
amd_binary, following the precedent already in the file for amd_tsan.

This is a workaround. It converts failures into slow runs — a test that would have failed
now burns up to 10+ minutes of CI — and it does nothing for the TOO_SLOW failures above.

What a real fix would look like

Ordered by how much of the problem they remove:

  1. Serve the test datasets from close to the runners — an S3 mirror in the runners' region,
    Hetzner object storage, or a caching HTTP proxy in the runner network. This removes both
    failure modes.
  2. Pre-warm filesystem_caches/stateful/ in the runner image, so the first read never
    goes over the network.
  3. Stop randomizing enable_filesystem_cache for stateful tests — removes the trigger
    but diverges from upstream's clickhouse-test. There is precedent in the same file:
    the azure job already sets --no-random-settings for exactly this kind of reason.

Option 1 is the only one that also fixes the TOO_SLOW failures and any future test that
reads remote data.

Open question for infra

DiskConnectionsReset: 145 (of 261 requests) appears on CI runners but not on a
developer machine running the same query. Connection reuse is poor in both, but something
is actively dropping connections in the CI network. Worth checking for a proxy, NAT or
firewall idle-timeout on the runner network — if that is fixed, the per-request cost drops
by the ~300ms handshake even without moving the data.

Activity

  1. added
    bug
    cicd
    on Aug 18, 2026
  2. changed the title [-]CI: stateless tests time out because our runners are far from the S3 test-data bucket[/-] [+]CI: stateless tests time out due to network latency between our runners and the S3 test-data bucket[/+] on Aug 18, 2026
  3. CarlosFelipeOR commented on Aug 20, 2026

    @CarlosFelipeOR
    CollaboratorAuthor

    Two more tests hitting this in the latest branch run (32308417635):

    • 03634_autopr_input_bytes_estimation — reads test.hits from the web disk. Died at 1200.04s, after we had already raised the timeout from 600s to 1200s. Failure rate 1.502% vs 0.0419% upstream.

    • 04510_s3_explicit_url_named_secret_mask — worth noting because it never touches the dataset bucket; all its URLs are localhost:11111. A single CREATE TABLE ... ENGINE = S3 with role_arn and google_adc_refresh_token spent over 300s, because those credentials make ClickHouse call AWS STS and Google's OAuth endpoint over the network. Failure rate 2.719% vs 0.0367% upstream, and 12x slower at the median.

    The second one suggests the problem isn't limited to the dataset bucket — it's external endpoints from the runners in general.

  4. strtgbb commented on Aug 20, 2026

    @strtgbb
    Collaborator

    I have looked into the options for mirroring the test.hits (and TPC) data and I have good news.
    Most of the connections (and all of the heavy ones) use disk(type=web, so the data does not actually need to be hosted on S3.
    We already have a server for caching docker images, I will look into reusing it to mirror the test.hits and TPC data, about 2GB total.
    After that, we can point the web disk calls to it and revert the extended timeouts from #2223 and the workaround in 481d664.

  5. CarlosFelipeOR commented on Aug 21, 2026

    @CarlosFelipeOR
    CollaboratorAuthor

    Mirror approach looks right, and reverting 481d664 should follow from it.

    One caveat on reverting the timeouts from #2223: 04070_url_base_setting would start failing again. It never touches the dataset — it fails on DNS, doing 25 .invalid lookups in series that take ~38s each on the runners instead of ~40ms. That's ~950s, so it needs the 1200s timeout regardless of the mirror. Details in #2250.

    Also worth separating: the --dns-search='.' part of #2223 is independent of the timeouts and halved that lookup cost, so it's worth keeping either way.

  6. CarlosFelipeOR commented on Sep 11, 2026

    @CarlosFelipeOR
    CollaboratorAuthor

    The antalya-26.6 release run 34481990917 was hit by this. Recording the numbers so they aren't lost.

    2026-09-10 release run: 60 report lines across 23 jobs trace to 65.108.242.32:6000. It surfaced under five different labels — Server died, Cannot start clickhouse-server, Test script failed, Hung check failed, and plain test failures — which is why it read as five problems instead of one.

    Every failure whose text names the host, by day (query):

    Day Affected tests Jobs PRs
    2026-09-02 27 10 2
    2026-09-08 42 11 5
    2026-09-10 75 21 8
    2026-09-11 2 2 2

    2026-09-02 is the first day the endpoint appears in the CI database at all, so the mirror was under-provisioned from the day it went in. The count undercounts: a TPC-DS test killed by the 1200 s harness timeout leaves a process-kill trace rather than a server exception, so it never matches the filter. On 2026-09-10 that hides another 21 FAIL and 60 BROKEN.

    The mirror's resources were increased on 2026-09-11 and the data agrees it's fixed: last timeout at 16:00Z, then 2,372 TPC-DS reads through 23:00Z with zero failures.

    Three things on our side amplify any future hiccup, and more resources don't remove them: TPC-DS tables are web disks with no cache; tpcds.* metadata loads at startup, so an unreachable mirror gives Cannot start clickhouse-server; and ATTACH AS REPLICATED walks the dataset disks, so it fails on purely local tables. Happy to open a separate issue for those.

  7. strtgbb commented on Sep 11, 2026

    @strtgbb
    Collaborator

    The initial deployment of the mirror was not able to keep up, leading to continued burst fails of TPS tests and test.hits.
    I have made two key changes to increase the serving capacity.

    1. The docker container was limited to 256MB of RAM. This was inherited from AI-written boilerplate. The limit is now removed and the container can access the system's full 8GB. Currently under moderate load the container uses 2GB.
    2. Nginx default of worker_connections 1024 is insufficient. It has been raised to 4096 and the log no longer has bursts of the worker_connections are not enough message.

    The new configuration was finalized by 4pm eastern time on 2026-09-11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

antalyabugcicd

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions