[CONJ-1007] Socket file descriptors are leaked after connecting with unix socket if DB is not up running Created: 2022-09-01 Updated: 2022-09-15 Resolved: 2022-09-02 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | None |
| Fix Version/s: | 2.7.7, 3.0.8 |
| Type: | Bug | Priority: | Major |
| Reporter: | Guopeng Liang | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
If the connector is configured using unix socket, and attempts to connect when the DB is not up (the path to unix socket does not exist or not able to connect), it fails as expected. However after that, a socket file descriptor is not closed and leaked. How to reproduce: Add a unit test like this:
Run the unit test in a Linux env, and set break points as shown. Below example shows the "after" condition only: #Find the process ID and replace here > netstat -apnx | grep $pid > lsof -p $pid | grep socket | wc -l |
| Comments |
| Comment by Diego Dupin [ 2022-09-02 ] | |||||
|
nice detailed description ! | |||||
| Comment by Guopeng Liang [ 2022-09-02 ] | |||||
|
Thank you Diego! I was about to submit a pull request though. I was about to fix that in UnixDomainSocket, which is more specific. Your fix seems to be in the code path which applies to TCP as well? I don't see any issue currently when using TCP connection which leaks and the issue is specific to Unix socket. Generally I also think we should not expect a resource needs to be closed explicitly, if it fails to create or connect. Another concern is that, for some reason we want to stick with version 1.x or 2.x. Your fix applies to ConnectionHelper which does not exist in older versions. Fixing in UnixDomainSocket is more specific and can apply to all versions in the same way. What is your opinion? | |||||
| Comment by Guopeng Liang [ 2022-09-02 ] | |||||
|
It might not be the same cause of | |||||
| Comment by Guopeng Liang [ 2022-09-02 ] | |||||
|
I also found that this issue SEEMS to be fixed in latest 1.x by this commit: https://github.com/mariadb-corporation/mariadb-connector-j/commit/a8f8ab9acb80876c65303eb55950a6ab16de3c16, with this code snip:
The code has been changed a lot towards 2.x and 3.x so this logic seems not preserved in 2.x and 3.x. However I remember I still had the leaking issue when using latest 1.x version in the application. I need to retest it again to confirm. | |||||
| Comment by Diego Dupin [ 2022-09-05 ] | |||||
|
1.x just become non supported. (java 7 EOL + 5 years support) | |||||
| Comment by Guopeng Liang [ 2022-09-06 ] | |||||
|
Thank you again. I see you also made similar fix to 2.x version as well which is perfect for us. When are you planning on releasing it? | |||||
| Comment by Diego Dupin [ 2022-09-07 ] | |||||
|
This is the only issue for 2.7.7 for now. Release date for 2.7.7 is programmed to the 1st December. | |||||
| Comment by Guopeng Liang [ 2022-09-15 ] | |||||
|
| |||||
| Comment by Diego Dupin [ 2022-09-15 ] | |||||
|
|