Start/stop servers when listen_host/*_port changes#30549
Start/stop servers when listen_host/*_port changes#30549vitlibar merged 1 commit intoClickHouse:masterfrom
listen_host/*_port changes#30549Conversation
listen_host/*_port changes
76ab2ef to
d65b9ce
Compare
d65b9ce to
0df72bb
Compare
|
Sorry for the delay |
There was a problem hiding this comment.
The tests look great, thank you!
src/Server/TCPServer.h
Outdated
There was a problem hiding this comment.
Poco::Net::TCPServer already has the function stop(). It looks misleading to have both stop() and close() functions in TCPServer. Can we rename close() -> stop() and also call Poco::Net::TCPServer::stop() in this function?
src/Server/TCPServer.h
Outdated
There was a problem hiding this comment.
So the only difference between TCPServer and Poco::Net::TCPServer is that TCPServer closes the socket. Can you please add a comment why Poco::Net::TCPServer::stop() is not enough and we also need to close the socker?
src/Server/PostgreSQLHandler.cpp
Outdated
There was a problem hiding this comment.
It seems it would be clearer to define a constant instead of using the magic number:
constexpr size_t connection_check_timeout = 1; /// 1 second
while (!in->poll(1000000 * connection_check_timeout))
programs/server/Server.cpp
Outdated
There was a problem hiding this comment.
We can probably make the code clearer if we add a new function named like updateServers(), and move the following code in there.
There was a problem hiding this comment.
Sharing of a mutex doesn't look very nice to me. Maybe it's better to change something. For example, it seems instead of passing servers_to_start_before_tables_, servers_lock_, servers_ we can pass a function of type std::function<std::vector<ProtocolServerMetrics>()>, where ProtocolServerMetrics is defined as following
struct ProtocolServerMetrics
{
String port_name;
size_t current_threads;
};
Thus we will able to turn both the mutex and the lists of servers back to simple local variables in Server.cpp, without necessity to share them with another module.
|
@Mergifyio update |
❌ Pull request can't be updated with latest base branch changesDetailsMergify needs the author permission to update the base branch of the pull request. |
9191242 to
79a0df0
Compare
This allows starting and stopping separately each protocol server without restarting ClickHouse. This also allows adding or removing `listen_host` entries, which start and stops servers for all enabled ports. When stopping a server, the listening socket is immediately closed (and available for another server). Protocols with persistent connections try to wait for any currently running query to finish before closing the connection, but idle connection are closed quickly (depending on how often the protocol is polled). An extra ProfileEvent is added, `MainConfigLoads`, it is incremented every time the configuration is reloaded. This helps when trying to assess whether the new configuration was applied.
79a0df0 to
ffc1fca
Compare
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Start and stop servers when hosts and ports configuration changes
Detailed description / Documentation draft:
Start and stop each protocol server without restarting ClickHouse.
This also allows adding or removing
listen_hostentries, which start and stops servers for all enabled ports.When stopping a server, the listening socket is immediately closed (and available for another server).
Protocols with persistent connections try to wait for any currently running query to finish before closing the connection, but idle connection are closed quickly (depending on how often the protocol is polled).
An extra ProfileEvent is added,
MainConfigLoads, it is incremented every time the configuration is reloaded.This helps when trying to assess whether the new configuration was applied.