[CONJ-382] Leaked Sockets when server reach maximum connections Created: 2016-10-28  Updated: 2022-09-15  Resolved: 2016-11-07

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: None
Fix Version/s: 1.5.5, 1.1.10

Type: Bug Priority: Minor
Reporter: Diego Dupin Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to CONJ-1007 Socket file descriptors are leaked af... Closed

 Description   

reporting some issue :

We are using mariadb-java-client-1.1.9 and have an issue when the maximum connections is reached on the MariaDB database.

When trying to connect to a MariaDB database where the max connections was reached, the following exception is thrown: java.io.EOFException unexpected end of stream, read 0 bytes from 4. At this point the socket does not get closed and it leaks.

Here is the stack trace from the Exception:
MySQLProtocol.connect(String, int) line: 544
MySQLProtocol.connect() line: 722
MySQLProtocol.<init>(JDBCUrl, String, String, Properties) line: 281
Driver.connect(String, Properties) line: 111
DriverManager.getConnection(String, Properties, Class<?>) line: 664
DriverManager.getConnection(String, Properties) line: 208

The MySQLProtocol class where the exception is thrown is org.mariadb.jdbc.internal.mysql.MySQLProtocol.

When we execute netstat -pan we have the following list of sockets:
tcp 1 0 10.9.16.220:57313 10.9.16.224:3306 CLOSE_WAIT 9400/java

tcp 1 0 10.9.16.220:57086 10.9.16.224:3306 CLOSE_WAIT 9400/java
tcp 0 0 10.9.16.220:57159 10.9.16.224:3306 CLOSE_WAIT 9400/java

tcp 0 0 10.9.16.220:57151 10.9.16.224:3306 CLOSE_WAIT 9400/java
....

The socket should get properly closed in such a scenario.



 Comments   
Comment by Guopeng Liang [ 2022-09-15 ]

For information, the bug reported in CONJ-1007 was also fixed by the resolution of this CR.

Generated at Thu Feb 08 03:15:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.