Skip to content

Commit

Permalink
Close backend connections for logical/phys replication on detach (#563)
Browse files Browse the repository at this point in the history
* Close backend connections for logical/phys replication on detach

* fmt
  • Loading branch information
reshke authored Jan 31, 2024
1 parent 806aebd commit ccd4dbf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sources/router.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,19 @@ 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,
Expand Down

0 comments on commit ccd4dbf

Please sign in to comment.