[CONJ-513] Connector/J Leaking socket file descriptors when using unix domain sockets Created: 2017-08-23  Updated: 2022-09-05  Resolved: 2021-04-08

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.6.3
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Robert Goley Assignee: Diego Dupin
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

Ubuntu 12.04 and Ubuntu 14.04
Tomcat 7.0.57

JDK version : Zulu-7 7.20.0.3
Database : MariaDB 10.1.26
Driver version : 1.6.3

<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.4.Final</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.6.Final</version>
</dependency

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-hikaricp</artifactId>
<version>5.1.3.Final</version>
</dependency>

<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.6.3</version>
</dependency

  1. Used by Connector/J to access Unix Domain sockets
    <dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna</artifactId>
    <version>4.2.2</version>
    </dependency>
    <dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna-platform</artifactId>
    <version>4.2.2</version>
    </dependency

Attachments: Text File netstat.txt     Text File socket_fds.txt     Zip Archive ticket.zip    
Issue Links:
Relates
relates to CONJ-1007 Socket file descriptors are leaked af... Closed

 Description   

We have a servlet application running in Tomcat 7 that is leaking socket files. I have tracked it back to the idle timeout reaping of connections. The leaked socket fd count increases by exactly the number of connections in the hibernate.hikari.maximumPoolSize setting (20) at exactly the idle timeout reaping interval. This happens without the application logged in or doing anything. You can watch the /proc/$PID/fd directory and just see the file descriptor count increase. I will attach pom and other setup files for reference.

This only happens when using the connector/j jdbc driver with a url that uses unix domain sockets. It does not happen with regular TCP/IP connections to the localhost server. I believe that either the connector/j is leaving a leftover socket file open in the app when the connection is closed or that the particular usage from hibernate-hikaricp doesn't allow it to clean up that last connection piece.



 Comments   
Comment by Diego Dupin [ 2017-08-31 ]

reproduced using pool hikaricp, without, it doesn't seem to occur. Now analysing

Comment by Diego Dupin [ 2017-09-04 ]

Erronous last comment, those socket where not due to pooling/connections.
I didn't reproduced any leak.

Can you add result of folowing command : "lsof -a -p <pid>" and "netstat -v" ?

Comment by Robert Goley [ 2017-09-05 ]

Just added the captured output of both commands. It is the large number of socket file descriptors with the "can't identify protocol" description that grows when the socket pool idleTimeout is reached that seems to be the problem. This happens using a JDBC connection url like "jdbc.url=jdbc:mariadb://localhost:3306/appname?localSocket=/var/run/mysqld/mysqld.sock" that uses unix domain sockets but not one like jdbc.url=jdbc:mariadb://localhost:3306/appname" that only uses TCP/IP sockets.

Comment by Robert Goley [ 2017-11-07 ]

This issue is specific to using the JNA unix socket option with hibernate-hikaricp 5.1.3 which includes hikaricp 2.3.x. This is regularly reproducible with it. Every time the maxLifetime period is reached, the number of socket file descriptors is increased by the number of minimumIdle connections specified.

However, dropping hibernate-hikaricp in favor of the HikariCP-java7 (2.4.13) resolves this issue without changing any other setting. That would seem to show the issue is actually with HikariCP 2.3.x and not the MariaDB Connector/J.

Comment by Diego Dupin [ 2021-04-08 ]

closing because not reproduced, and stalled for 4 years

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