-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection leak when DriverDatabaseConnectionManager#createConnections throw exception #33831
Comments
if (1 == connectionSize) {
Connection connection = createConnection(databaseName, dataSourceName, dataSource, connectionContext.getTransactionContext());
try {
methodInvocationRecorder.replay(connection);
} catch (final SQLException ex) {
connection.close();
throw ex;
}
return Collections.singletonList(connection);
} |
yes 。we should catch the SQLException and close the connection。 |
Are you going to submit a PR? The failing unit tests are clearly not in someone else's hands. |
But then again, the unit tests I wrote didn't have connection leaks, there was always extra logic to close all connections. You need to provide independent unit tests. |
Sorry I do not know how to mock the connection leaks in the unit tests 。 |
Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use?
5.5.0
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Expected behavior
Actual behavior
Reason analyze (If you can)
In line 342, step 1, a database connection is obtained from the database connection pool.
In line 343, step 2, the previously recorded method is called for method replay.
However, if an exception was throwed from step2(for example the database server crashed), there is no opportunity to call the connection’s close method, leading to a connection leak.
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
Example codes for reproduce this issue (such as a github link).
The text was updated successfully, but these errors were encountered: