Add uuid to identify connection timings (#1992)

* Adding unique identifier for connection establishment start and stop debug timings.

* Fix to print both variables
pull/2238/head
Chris Hill 3 months ago committed by GitHub
parent a43eecdbb3
commit 8f9c0b5935
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -352,6 +352,7 @@ abstract class PoolBase
private Connection newConnection() throws Exception private Connection newConnection() throws Exception
{ {
final var start = currentTime(); final var start = currentTime();
final var id = java.util.UUID.randomUUID();
Connection connection = null; Connection connection = null;
try { try {
@ -359,21 +360,24 @@ abstract class PoolBase
final var username = credentials.getUsername(); final var username = credentials.getUsername();
final var password = credentials.getPassword(); final var password = credentials.getPassword();
logger.debug("{} - Attempting to create/setup new connection: {} ", poolName, id.toString());
connection = (username == null) ? dataSource.getConnection() : dataSource.getConnection(username, password); connection = (username == null) ? dataSource.getConnection() : dataSource.getConnection(username, password);
if (connection == null) { if (connection == null) {
throw new SQLTransientConnectionException("DataSource returned null unexpectedly"); throw new SQLTransientConnectionException("DataSource returned null unexpectedly");
} }
setupConnection(connection); setupConnection(connection);
logger.debug("{} - Established new connection: {}", poolName, id);
lastConnectionFailure.set(null); lastConnectionFailure.set(null);
return connection; return connection;
} }
catch (Exception e) { catch (Exception e) {
if (connection != null) { if (connection != null) {
quietlyCloseConnection(connection, "(Failed to create/setup connection)"); quietlyCloseConnection(connection, "(Failed to create/setup connection for id:".concat(id.toString()));
} }
else if (getLastConnectionFailure() == null) { else if (getLastConnectionFailure() == null) {
logger.debug("{} - Failed to create/setup connection: {}", poolName, e.getMessage()); logger.debug("{} - Failed to create/setup connection: {} {}", poolName, e.getMessage(), id.toString());
} }
lastConnectionFailure.set(e); lastConnectionFailure.set(e);

Loading…
Cancel
Save