From fe5e675f01ecf6fb48dfb9ba7d50c4e8e823627b Mon Sep 17 00:00:00 2001 From: Manav Kumar Date: Mon, 22 Jul 2024 16:50:16 +0000 Subject: [PATCH] [#23218] YSQL: Closing the backend connection on receiving the error "Database might have been dropped by another user" Summary: This diff fixes one of the test `org.yb.pgsql.TestPgDropDatabase#testRecreateDatabase` failing with ysql connection manager. **Reason for the test failure** For errors like "Database might have been dropped by another user", ysql connection manager throws the FATAL packet without detaching or closing the backend process before closing the client connection. Due to which an assert failure happened while removing the client connection from the pool which leads to crash and restart of ysql connection manager process. Therefore all the pre existed logical connection present crash also starts failing. **Fix** After connection manager receives an error message "Database might have been dropped by another user" from postgres, a ERROR packet is sent to client instead of FATAL (in order to mimic same behaviour as without connection manager) and corresponding logical and physical connections are closed. Test Plan: Jenkins: all tests, enable connection manager Ensure below test runs successfully with ysql connection manager: `./yb_build.sh --enable-ysql-conn-mgr-test --java-test org.yb.pgsql.TestPgDropDatabase#testRecreateDatabase` Reviewers: asrinivasan, nkumar, skumar Reviewed By: asrinivasan Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D36461 --- src/odyssey/sources/backend.c | 3 ++- src/odyssey/sources/frontend.c | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/odyssey/sources/backend.c b/src/odyssey/sources/backend.c index fac07f711f6a..c0e12072341d 100644 --- a/src/odyssey/sources/backend.c +++ b/src/odyssey/sources/backend.c @@ -97,7 +97,8 @@ void od_backend_error(od_server_t *server, char *context, char *data, if (server->client != NULL && ((od_client_t *)server->client)->type == OD_POOL_CLIENT_EXTERNAL) - od_frontend_fatal(server->client, KIWI_CONNECTION_DOES_NOT_EXIST, error.hint); + od_frontend_error(server->client, KIWI_CONNECTION_DOES_NOT_EXIST, + error.hint, od_io_error(&server->io)); } } } diff --git a/src/odyssey/sources/frontend.c b/src/odyssey/sources/frontend.c index f01b3c88a197..826afc79a3dc 100644 --- a/src/odyssey/sources/frontend.c +++ b/src/odyssey/sources/frontend.c @@ -1909,14 +1909,6 @@ static void od_frontend_cleanup(od_client_t *client, char *context, if (od_frontend_status_is_err(status)) { od_error_logger_store_err(l, status); - if (yb_is_route_invalid(client->route)) { - if (client->type == OD_POOL_CLIENT_EXTERNAL) - od_frontend_fatal( - client, KIWI_CONNECTION_FAILURE, - "Database might have been dropped by another user"); - return; - } - if (route->extra_logging_enabled && !od_route_is_dynamic(route)) { od_error_logger_store_err(route->err_logger, status);