Skip to content

Commit

Permalink
[#23218] YSQL: Closing the backend connection on receiving the error …
Browse files Browse the repository at this point in the history
…"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
  • Loading branch information
Manav Kumar committed Jul 23, 2024
1 parent 4ee3511 commit fe5e675
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/odyssey/sources/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/odyssey/sources/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fe5e675

Please sign in to comment.