v.21.7Improvement

Respect max_distributed_connections in insert_distributed_sync to avoid max_thread_pool_size issues

Respect max_distributed_connections for insert_distributed_sync (otherwise for huge clusters and sync insert it may run out of max_thread_pool_size). #24754 (Azat Khuzhin).
Ensure insert_distributed_sync respects the max_distributed_connections setting to prevent exhausting max_thread_pool_size in large clusters.

Why it matters

This feature addresses the issue where synchronous inserts into distributed tables could spawn too many connections, potentially exceeding the max_thread_pool_size limit and causing resource exhaustion. By respecting the max_distributed_connections limit, it improves stability and resource management for large-scale ClickHouse deployments.

How to use it

To apply this feature, ensure that insert_distributed_sync is enabled and configure the max_distributed_connections setting appropriately to limit the number of concurrent connections during synchronous distributed inserts. No additional action is required as the feature is integrated into the system behavior.