From 31abc26424d47312c7f53271e5253e3a77838ba9 Mon Sep 17 00:00:00 2001 From: reshke Date: Wed, 31 Jan 2024 10:09:38 +0000 Subject: [PATCH] Close backend connections for logical/phys replication on detach --- sources/router.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sources/router.c b/sources/router.c index 60724f569..92aba566a 100644 --- a/sources/router.c +++ b/sources/router.c @@ -695,8 +695,20 @@ void od_router_detach(od_router_t *router, od_client_t *client) client->server = NULL; server->client = NULL; if (od_likely(!server->offline)) { - od_pg_server_pool_set(&route->server_pool, server, - OD_SERVER_IDLE); + od_instance_t *instance = server->global->instance; + if (route->id.physical_rep || route->id.logical_rep) { + od_debug(&instance->logger, "expire-replication", NULL, server, + "closing replication connection"); + server->route = NULL; + od_backend_close_connection(server); + od_pg_server_pool_set(&route->server_pool, server, + OD_SERVER_UNDEF); + od_backend_close(server); + } else { + + od_pg_server_pool_set(&route->server_pool, server, + OD_SERVER_IDLE); + } } else { od_instance_t *instance = server->global->instance; od_debug(&instance->logger, "expire", NULL, server,