Skip to content

Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes - #103080

Merged
azat merged 4 commits into
ClickHouse:masterfrom
azat:context-user-network-throttler
Apr 22, 2026
Merged

azat merged 4 commits into
ClickHouse:masterfrom
azat:context-user-network-throttler

Conversation

@azat

@azat azat commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Apply max_network_bandwidth_for_user/max_network_bandwidth_for_all_users to remote filesystem reads/writes

max_network_bandwidth_for_user and max_network_bandwidth_for_all_users used to limit only the distributed network layer. Extend them so that the same per-user / per-all-users bandwidth caps also apply to reads/writes from remote filesystems (e.g. S3), in addition to any per-query max_remote_read_network_bandwidth limit on top.

Note: historically we use separate settings for limiting reading from remote, but I did not want to introduce more extra settings, curious what your opinion on this

Version info

  • Merged into: 26.5.1.13 (included in 26.5 and later)
  • Backported to: 26.4.5.108, 26.3.10.32

@azat
azat requested a review from serxa April 18, 2026 21:55
@clickhouse-gh

clickhouse-gh Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b832d8c]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan_ubsan, db disk, old analyzer, 4/6) FAIL
test_backup_restore_new/test.py::test_backup_all[True] FAIL cidb
Integration tests (arm_binary, distributed plan, 4/4) FAIL
test_backup_restore_new/test.py::test_backup_all[True] FAIL cidb
Integration tests (amd_tsan, 4/6) FAIL
test_backup_restore_new/test.py::test_backup_all[True] FAIL cidb
Integration tests (amd_msan, 4/6) FAIL
test_backup_restore_new/test.py::test_backup_all[True] FAIL cidb
Fast test (arm_darwin) ERROR

AI Review

Summary

This PR wires max_network_bandwidth_for_user / max_network_bandwidth_for_all_users into remote filesystem read/write throttlers and adds profile events, plus a new stateless test around S3-backed read/write throttling. The code changes look correct, but test coverage is still incomplete for the max_network_bandwidth_for_all_users path.

Tests
  • ⚠️ Add a dedicated scenario that sets only max_network_bandwidth_for_all_users (with max_network_bandwidth_for_user = 0) and validates throttling/profile events for both remote read and remote write paths. The current test validates only the per-user setting.
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: ⚠️ Request changes
  • Minimum required actions:
    • Add coverage for the max_network_bandwidth_for_all_users behavior introduced by this PR.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Apr 18, 2026
@azat
azat force-pushed the context-user-network-throttler branch from 8fc2f83 to 4858ab5 Compare April 18, 2026 21:57
@azat azat changed the title Apply max_network_bandwidth_for_user to remote and local read/write Apply max_network_bandwidth_for_{user,all_users} to remote and local read/write Apr 18, 2026
@azat azat changed the title Apply max_network_bandwidth_for_{user,all_users} to remote and local read/write Apply max_network_bandwidth_for_{user,all_users{ to remote filesystem reads Apr 18, 2026
@azat azat changed the title Apply max_network_bandwidth_for_{user,all_users{ to remote filesystem reads Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads Apr 18, 2026
@azat
azat force-pushed the context-user-network-throttler branch from 4858ab5 to f888d47 Compare April 18, 2026 22:02
@azat azat changed the title Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes Apr 18, 2026
@azat
azat force-pushed the context-user-network-throttler branch from f888d47 to 63955a8 Compare April 18, 2026 22:05
Comment thread src/Interpreters/Context.cpp Resolved
@azat
azat force-pushed the context-user-network-throttler branch from 63955a8 to 0094150 Compare April 19, 2026 07:45
Attribute throttling performed by `max_network_bandwidth_for_user` and
`max_network_bandwidth_for_all_users` to dedicated profile events
(`UserThrottler{Bytes,SleepMicroseconds}` and
`AllUsersThrottler{Bytes,SleepMicroseconds}`), so that their contribution
is visible in `system.query_log.ProfileEvents` next to the existing
per-query / per-server throttlers.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@azat
azat force-pushed the context-user-network-throttler branch from 0094150 to d3ad257 Compare April 19, 2026 07:53
…rites

`max_network_bandwidth_for_user` and `max_network_bandwidth_for_all_users`
used to limit only the distributed network layer. Extend them so that
the same per-user / per-all-users bandwidth caps also apply to reads
from and writes to remote filesystems (e.g. S3), in addition to any
per-query `max_remote_read_network_bandwidth` /
`max_remote_write_network_bandwidth` on top. Local filesystem IO is
unaffected, since this setting is about network bandwidth.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@azat
azat force-pushed the context-user-network-throttler branch from d3ad257 to 8251291 Compare April 19, 2026 08:23
fm4v added a commit that referenced this pull request Apr 19, 2026
…lection

Files like `ProfileEvents.cpp`, `Settings.cpp`, `SettingsChangesHistory.cpp`,
`ErrorCodes.cpp`, and `CurrentMetrics.cpp` are pure declaration registries —
every query emits profile events and reads settings, so coverage for any changed
line in these files matches thousands of tests. A typical PR only adds a new
`extern const Event ...` line, yet the targeted check picks up every
`profile_events` / `system_processes` / `system_events` test in the suite.

Example: #103080 added 4 lines to
`src/Common/ProfileEvents.cpp` and dozens of unrelated profile-events tests
were selected via the broad-tier2 path.

Skip these files in the coverage, sibling, indirect, and keyword-fallback
passes. The real signal for such PRs lives in the other files they touch
(e.g. `Context.cpp`, `ProcessList.cpp`), which remain fully analyzed.
@azat
azat force-pushed the context-user-network-throttler branch from 7d31f44 to 4ebd99b Compare April 19, 2026 20:52
@nikita-vanyasin
nikita-vanyasin requested a review from CheSema April 20, 2026 15:12

@CheSema CheSema left a comment

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.

add user's throttler is ok.

@azat

azat commented Apr 20, 2026

Copy link
Copy Markdown
Member Author

Actually this implementation (and non global throttling in general) may not work, since with current implementation it can lead to blocking thread pool that is used for reads, so if some user will throttle, others may be blocked by it (if the thread pool will not be big enough), ideally, we need something better then just sleep before read.

Though the same problem we have everywhere...

@azat
azat marked this pull request as draft April 20, 2026 16:07
Comment thread src/Interpreters/Context.cpp Resolved
@serxa

serxa commented Apr 20, 2026 •

Copy link
Copy Markdown
Member

Though the same problem we have everywhere...

Yes, this is a problem but it is unrelated problem, I would say. For now, the best thing we can rely on is that number of queries can be limited for user. And number of IO threads is limited per query.

And yes, indeed this PR will not help to resolve it. Independent per user limits will only create more waiting threads.

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Apr 22, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Apr 22, 2026
Cherry pick #103080 to 26.1: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes
robot-clickhouse added a commit that referenced this pull request Apr 22, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Apr 22, 2026
Cherry pick #103080 to 26.2: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes
robot-clickhouse added a commit that referenced this pull request Apr 22, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Apr 22, 2026
Cherry pick #103080 to 26.3: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes
robot-clickhouse added a commit that referenced this pull request Apr 22, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Apr 22, 2026
@azat

azat commented Apr 23, 2026

Copy link
Copy Markdown
Member Author

Backports will include #103387 as well

azat added a commit that referenced this pull request Apr 23, 2026
Backport #103080 to 26.1: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes
azat added a commit that referenced this pull request Apr 23, 2026
Backport #103080 to 26.3: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes
alexey-milovidov added a commit that referenced this pull request May 1, 2026
Backport #103080 to 26.2: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes
@azat azat added v26.4-must-backport and removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore labels Jun 30, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 30, 2026
fm4v added a commit that referenced this pull request Jul 7, 2026
Backport #103080 to 26.4: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
…user,all_users} to remote filesystem reads/writes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.12-must-backport v26.2-must-backport v26.3-must-backport v26.4-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants