v.21.9Improvement
Do Asynchronous Connection Draining for Distributed Queries with New Server Settings
Do connection draining asynchonously upon finishing executing distributed queries. A new server setting is addedmax_threads_for_connection_collectorwhich specifies the number of workers to recycle connections in background. If the pool is full, connection will be drained synchronously but a bit different than before: It's drained after we send EOS to client, query will succeed immediately after receiving enough data, and any exception will be logged instead of throwing to the client. Added settingdrain_timeout(3 seconds by default). Connection draining will disconnect upon timeout. #25674 (Amos Bird).
Why it matters
This feature improves connection resource management and query responsiveness by recycling connections in the background, preventing blocking synchronous drains and ensuring queries succeed promptly without client-side exceptions caused by connection draining.How to use it
Enable asynchronous connection draining by configuring the new server settingmax_threads_for_connection_collector to specify the number of background workers handling connection recycling. Adjust drain_timeout (default is 3 seconds) to set the timeout for disconnecting draining connections. If the worker pool is full, draining falls back to a modified synchronous approach that sends EOS to the client before draining without throwing exceptions.