Skip to content

Fix flaky test 04103_user_network_bandwidth_throttler - #103586

Merged
tiandiwonder merged 1 commit into
ClickHouse:masterfrom
tiandiwonder:fix-flaky-04103-user-network-bandwidth-throttler
Jun 5, 2026
Merged

tiandiwonder merged 1 commit into
ClickHouse:masterfrom
tiandiwonder:fix-flaky-04103-user-network-bandwidth-throttler

Conversation

@tiandiwonder

@tiandiwonder tiandiwonder commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Add no-random-settings tag to fix flaky test 04103_user_network_bandwidth_throttler.

CI randomized settings can inject remote_filesystem_read_prefetch=0 and allow_prefetched_read_pool_for_remote_filesystem=0, which disable S3 prefetch. On a heavily loaded TSAN machine running parallel tests, this can make the natural S3 read rate drop below the 1 MB/s throttle limit. When natural rate < throttle limit, the token bucket never goes negative and the throttler never sleeps — UserThrottlerSleepMicroseconds stays at 0 while UserThrottlerBytes is correctly counted, causing the third check to fail transiently.

The write side is unaffected because its data source (numbers(1e6)) is memory/CPU-bound and always exceeds 1 MB/s regardless of machine load.

Fixes #103422
Follow-up for: #103080
CI failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102547&sha=83f565de244bc2f42b2f51098ea6bbef4bcf2c9d&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%202%2F2%29

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):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.6.1.401

@clickhouse-gh

clickhouse-gh Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c40c8f2]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_asan_ubsan, distributed plan, parallel, 2/2) FAIL
04122_serialization_time64_formats FAIL cidb, issue ISSUE CREATED
04122_serialization_time64_formats FAIL cidb, issue ISSUE CREATED
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage, parallel) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_debug, parallel) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_tsan, parallel, 2/2) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_msan, WasmEdge, parallel, 2/2) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_debug, distributed plan, s3 storage, parallel) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (amd_tsan, s3 storage, parallel, 2/2) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED
Stateless tests (arm_binary, parallel) FAIL
04122_serialization_time64_formats FAIL cidb IGNORED
04122_serialization_time64_formats FAIL cidb IGNORED

AI Review

Summary

This PR makes 04103_user_network_bandwidth_throttler deterministic under CI randomized settings by adding the no-random-settings test tag and documenting why randomized S3 prefetch settings can invalidate the throttling-sleep assertion. The change is narrowly scoped to test metadata/comments, and I did not find correctness, safety, or compliance issues in the diff.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci submodule changed At least one submodule changed in this PR. labels Apr 27, 2026
Add `no-random-settings` tag to prevent CI randomized settings from
disabling S3 prefetch (`remote_filesystem_read_prefetch=0`,
`allow_prefetched_read_pool_for_remote_filesystem=0`), which can make
the natural S3 read rate drop below the 1 MB/s throttle limit. When
natural rate < throttle limit, the token bucket never goes negative and
the throttler never sleeps, causing `UserThrottlerSleepMicroseconds` to
be 0 even though `UserThrottlerBytes` is correctly counted — the third
check then fails transiently.

Fixes ClickHouse#103422
CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102547&sha=83f565de244bc2f42b2f51098ea6bbef4bcf2c9d&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%202%2F2%29

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@tiandiwonder
tiandiwonder force-pushed the fix-flaky-04103-user-network-bandwidth-throttler branch from d5b374f to c40c8f2 Compare April 27, 2026 06:57
# Tags: no-fasttest, long, no-random-settings
# no-fasttest: needs S3, and the test is slow (exercises throttling)
# no-random-settings: S3 prefetch settings affect read throughput; disabling prefetch can make
# natural read rate drop below the 1 MB/s throttle limit, causing the throttler to never sleep

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think it is related to prefetching, and it does fail even with all prefetching enabled - https://play.clickhouse.com/play?user=play&run=1#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIGNoZWNrX25hbWUsIHJlZ2V4cEV4dHJhY3QodGVzdF9jb250ZXh0X3JhdywgJy0tbWF4X3RocmVhZHNccysoXFMrKScsIDEpLCByZXBvcnRfdXJsCkZST00gY2hlY2tzCldIRVJFIGNoZWNrX3N0YXJ0X3RpbWUgPj0gbm93KCkgLSBJTlRFUlZBTCA2MCBkYXkKLy8gICAgQU5EIChoZWFkX3JlZiA9ICdtYXN0ZXInIEFORCBzdGFydHNXaXRoKGhlYWRfcmVwbywgJ0NsaWNrSG91c2UvJykpCiAgICBBTkQgdGVzdF9zdGF0dXMgIT0gJ1NLSVBQRUQnCiAgICBBTkQgKHRlc3Rfc3RhdHVzIExJS0UgJ0YlJyBPUiB0ZXN0X3N0YXR1cyBMSUtFICdFJScpCiAgICBBTkQgY2hlY2tfc3RhdHVzICE9ICdzdWNjZXNzJwogICAgQU5EIGNoZWNrX25hbWUgTk9UIExJS0UgJ2xpYkZ1enplciUnCiAgICBBTkQgY2hlY2tfbmFtZSAhPSAnQ2xpY2tIb3VzZSBLZWVwZXIgSmVwc2VuJwogICAgQU5EIGNoZWNrX25hbWUgTk9UIElMSUtFICclZXhwZXJpbWVudGFsJScKICAgIEFORCBwb3NpdGlvbih0ZXN0X25hbWUsICcwNDEwM191c2VyX25ldHdvcmtfYmFuZHdpZHRoX3Rocm90dGxlcicpID4gMAogICAgYW5kIHB1bGxfcmVxdWVzdF9udW1iZXIgIT0gMTAzMDgwCiAgICBhbmQgdGVzdF9jb250ZXh0X3JhdyBsaWtlICclYWxsb3dfcHJlZmV0Y2hlZF9yZWFkX3Bvb2xfZm9yX3JlbW90ZV9maWxlc3lzdGVtIDElJwogICAgYW5kIHRlc3RfY29udGV4dF9yYXcgbGlrZSAnJXJlbW90ZV9maWxlc3lzdGVtX3JlYWRfcHJlZmV0Y2ggMSUnCk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWU=

And it is not related to max_threads at all, it is OK to disable tests for sanitizers I think for now

And if it will fail after this (for i.e. debug build) then we will have CPU/Real traces, and also let's add trace_profile_events_list='UserThrottlerSleepMicroseconds,UserThrottlerBytes', trace_profile_events=1 and this will allow to make better guesses

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@tiandiwonder I guess you missed this comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@azat You're right — it's not prefetch-specific; it fails with prefetching enabled too. The real fragility was the throttle limit sitting just below the natural read rate, since fixed by lowering it to 200 KB/s. I've corrected the now-inaccurate no-random-settings comment in a follow-up (the merged PR couldn't be amended): #106947. Thanks for the catch.

@clickhouse-gh

clickhouse-gh Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Dear @arsenmuk, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@tiandiwonder
tiandiwonder added this pull request to the merge queue Jun 5, 2026
Merged via the queue into ClickHouse:master with commit 961aff5 Jun 5, 2026
151 of 165 checks passed
@tiandiwonder
tiandiwonder deleted the fix-flaky-04103-user-network-bandwidth-throttler branch June 5, 2026 01:16
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 5, 2026
pull Bot pushed a commit to sowelswl/ClickHouse that referenced this pull request Jun 7, 2026
The test asserts that ProfileEvents['UserThrottlerSleepMicroseconds'] is
greater than half of the target query duration. The throttler only sleeps
when the natural read rate exceeds the configured throttle limit; when the
natural rate drops close to the limit the token bucket never goes negative
and the throttler skips its sleep path (see `Throttler::throttle` in
`src/Common/Throttler.cpp`).

PR ClickHouse#103586 added `no-random-settings` to remove S3-prefetch settings as one
source of slow natural rate, but contention on the `Stateless tests
(amd_tsan, parallel, 2/2)` runner still occasionally drives the natural S3
read rate close to or below the previous 1 MB/s limit. Post-merge CIDB:
`pull_request_number != 0 AND check_start_time > 2026-06-05` shows 4
sightings (PRs ClickHouse#106222, ClickHouse#102039, ClickHouse#49966, ClickHouse#106184) all on amd_tsan parallel
2/2 with the `read 1 1 0` shape (duration ok, bytes ok, sleep below
threshold). All four PRs already include the `no-random-settings` tag, so
the remaining flakiness is contention-driven, not random-settings driven.

Drop the throttle limit and dataset 5x so the throttle is well below any
plausible natural rate (200 KB/s vs ~0.9 MB/s observed worst case = 4.5x
safety margin). Test wall-clock stays at ~8s. Local 10/10 runs against an
S3 disk produced sleep_us between 16.8s and 17.3s, comfortably above the
3.5s threshold.

Closes: ClickHouse#103422
Related: ClickHouse#103586
Related: ClickHouse#106184

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: 04103_user_network_bandwidth_throttler

4 participants