Skip to content

add hard limit for http client connection#91016

Merged
CheSema merged 4 commits intomasterfrom
chesema-max-connection
Nov 30, 2025
Merged

add hard limit for http client connection#91016
CheSema merged 4 commits intomasterfrom
chesema-max-connection

Conversation

@CheSema
Copy link
Copy Markdown
Member

@CheSema CheSema commented Nov 27, 2025

Changelog category (leave one):

  • Improvement

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

Now HTTP_CONNECTION_LIMIT_REACHED exception would be thrown when hard_limit for the http clients connection is reached. It is set as 20000 for the disk connections.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@CheSema CheSema requested a review from Copilot November 27, 2025 19:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds hard limit configurations for HTTP client connections across three connection groups (disk, storage, and http). When the hard limit is reached, an exception is thrown instead of allowing further connection creation.

  • Added hard_limit field to connection pool limits configuration
  • Implemented hard limit checking before connection creation with appropriate error handling
  • Added test coverage for the new hard limit functionality

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Core/ServerSettings.cpp Added three new server settings for hard limits (disk_connections_hard_limit, storage_connections_hard_limit, http_connections_hard_limit) with default values and reduced disk_connections_store_limit
src/Common/HTTPConnectionPool.h Added hard_limit field to the Limits struct with default value of 25000
src/Common/HTTPConnectionPool.cpp Implemented hard limit check in prepareNewConnection method and added new error code HTTP_CONNECTION_LIMIT_REACHED
src/Common/ErrorCodes.cpp Registered new error code HTTP_CONNECTION_LIMIT_REACHED (762)
programs/server/Server.cpp Wired up the new hard limit settings to HTTPConnectionPools initialization
src/Common/tests/gtest_connection_pool.cpp Renamed existing HardLimit test to StoreLimit and added new HardLimit test to verify exception throwing behavior

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Nov 27, 2025

Workflow [PR], commit [5f719f0]

Summary:

job_name test_name status info comment
Stateless tests (arm_asan, targeted) failure
03554_json_shared_data_tuple_map_with_buckets_serialization_compact_part_big FAIL cidb
01459_manual_write_to_replicas_quorum_detach_attach FAIL cidb, issue
02789_filesystem_cache_alignment FAIL cidb
01459_manual_write_to_replicas_quorum_detach_attach FAIL cidb, issue
01459_manual_write_to_replicas_quorum_detach_attach FAIL cidb, issue
01459_manual_write_to_replicas_quorum_detach_attach FAIL cidb, issue
01459_manual_write_to_replicas_quorum_detach_attach FAIL cidb, issue
02789_filesystem_cache_alignment FAIL cidb
02789_filesystem_cache_alignment FAIL cidb
02789_filesystem_cache_alignment FAIL cidb
7 more test cases not shown
Stateless tests (amd_msan, parallel) failure
00596_limit_on_expanded_ast FAIL cidb
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: FAIL cidb, issue
BuzzHouse (arm_asan) failure
Logical error: 'Function writeSlice expects same column types for GenericArraySlice and GenericArraySink.' FAIL cidb
Finish Workflow failure
python3 ./ci/jobs/scripts/workflow_hooks/pr_body_check.py failure
AST fuzzer (amd_tsan) error

@clickhouse-gh clickhouse-gh bot added the pr-improvement Pull request with some product improvements label Nov 27, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tiandiwonder tiandiwonder self-requested a review November 28, 2025 01:18
Copy link
Copy Markdown
Member

@tavplubix tavplubix left a comment

Choose a reason for hiding this comment

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

Please write the changelog entry

DECLARE(UInt64, disk_connections_warn_limit, 10000, R"(Warning massages are written to the logs if number of in-use connections are higher than this limit. The limit applies to the disks connections.)", 0) \
DECLARE(UInt64, disk_connections_store_limit, 30000, R"(Connections above this limit reset after use. Set to 0 to turn connection cache off. The limit applies to the disks connections.)", 0) \
DECLARE(UInt64, disk_connections_store_limit, 15000, R"(Connections above this limit reset after use. Set to 0 to turn connection cache off. The limit applies to the disks connections.)", 0) \
DECLARE(UInt64, disk_connections_hard_limit, 25000, R"(Exception is thrown at a creation attempt when this limit is reached. Set to 0 to turn off hard limitation. The limit applies to the disks connections.)", 0) \
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.

Maybe 20k?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lowered them

@CheSema CheSema added this pull request to the merge queue Nov 30, 2025
Merged via the queue into master with commit 5ed4ef0 Nov 30, 2025
123 of 130 checks passed
@CheSema CheSema deleted the chesema-max-connection branch November 30, 2025 16:06
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 30, 2025
@tavplubix tavplubix added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Dec 1, 2025
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Dec 1, 2025
robot-clickhouse-ci-1 added a commit that referenced this pull request Dec 1, 2025
Cherry pick #91016 to 25.11: add hard limit for http client connection
clickhouse-gh bot added a commit that referenced this pull request Dec 1, 2025
Backport #91016 to 25.11: add hard limit for http client connection
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Dec 1, 2025
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 Pull request should be backported intentionally. Use this label with great care! 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants