From 21f7974e05827d3229258694926fa5a34d581e47 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 8 Aug 2025 17:50:57 +0200 Subject: [PATCH] OPTIM: backend: set release on takeover for strict maxconn When strict maxconn is enforced on a server, it may be necessary to kill an idle connection to never exceed the limit. To be able to delete a connection from any thread, takeover is first used to migrate it on the current thread prior to its deletion. As takeover is performed to delete a connection instead of reusing it, argument can be set to true. This removes unnecessary allocations of resources prior to connection deletion. As such, this patch is a small optimization for strict maxconn implementation. Note that this patch depends on the previous one which removes any assumption in takeover implementation that thread isolation is active if is true. --- src/backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index 3f0411ca7..3b4aef681 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1487,7 +1487,7 @@ takeover_random_idle_conn(struct eb_root *root, int curtid) while (node) { hash_node = eb64_entry(node, struct conn_hash_node, node); conn = hash_node->conn; - if (conn && conn->mux->takeover && conn->mux->takeover(conn, curtid, 0) == 0) { + if (conn && conn->mux->takeover && conn->mux->takeover(conn, curtid, 1) == 0) { conn_delete_from_tree(conn); return conn; }