Skip to content

Commit 21f7974

Browse files
committed
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, <release> 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 <release> is true.
1 parent d971d3f commit 21f7974

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ takeover_random_idle_conn(struct eb_root *root, int curtid)
14871487
while (node) {
14881488
hash_node = eb64_entry(node, struct conn_hash_node, node);
14891489
conn = hash_node->conn;
1490-
if (conn && conn->mux->takeover && conn->mux->takeover(conn, curtid, 0) == 0) {
1490+
if (conn && conn->mux->takeover && conn->mux->takeover(conn, curtid, 1) == 0) {
14911491
conn_delete_from_tree(conn);
14921492
return conn;
14931493
}

0 commit comments

Comments
 (0)