[CONJ-435] "All pipe instances are busy" exception on multiple connections to the same named pipe Created: 2017-02-23  Updated: 2017-03-06  Resolved: 2017-03-06

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.4.6
Fix Version/s: 1.5.9

Type: Bug Priority: Major
Reporter: Philipp Kapfer Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows


Issue Links:
Relates
relates to CONJ-36 implement Windows named pipe support ... Closed

 Description   

We configured the MariaDB server and Connector/J to attempt connections via named pipe. In parallelized unit tests, multiple threads concurrently access different databases via this named pipe. In some cases, creating a new connection fails, because the server didn't yet handle the previous connection attempt. This results in the FileNotFoundException below.

According to the MSDN, this is a standard case and has to be handled by the client by trying the connection again after a backoff time. Such a mechanism was already implemented by another open-source JDBC driver, where a template for a Connector/J patch is readily available.

java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=13307)(type=master) : \\.\pipe\MySQL (Alle Pipeinstanzen sind ausgelastet)
	at org.mariadb.jdbc.internal.util.ExceptionMapper.get(ExceptionMapper.java:123)
	at org.mariadb.jdbc.internal.util.ExceptionMapper.throwException(ExceptionMapper.java:69)
	at org.mariadb.jdbc.Driver.connect(Driver.java:110)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at java.sql.DriverManager.getConnection(Unknown Source)
	... 39 more
Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: Could not connect to address=(host=localhost)(port=13307)(type=master) : \\.\pipe\MySQL (Alle Pipeinstanzen sind ausgelastet)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:718)
	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:471)
	at org.mariadb.jdbc.Driver.connect(Driver.java:105)
	... 42 more
Caused by: java.io.FileNotFoundException: \\.\pipe\MySQL (Alle Pipeinstanzen sind ausgelastet)
	at java.io.RandomAccessFile.open0(Native Method)
	at java.io.RandomAccessFile.open(Unknown Source)
	at java.io.RandomAccessFile.<init>(Unknown Source)
	at java.io.RandomAccessFile.<init>(Unknown Source)
	at org.mariadb.jdbc.internal.socket.NamedPipeSocket.connect(NamedPipeSocket.java:99)
	at org.mariadb.jdbc.internal.socket.NamedPipeSocket.connect(NamedPipeSocket.java:83)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connect(AbstractConnectProtocol.java:349)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:713)
	... 44 more



 Comments   
Comment by Philipp Kapfer [ 2017-02-23 ]

Further investigation showed that a working fix isn't as trivial as depicted in jDTS. To react on this specific error case, the exception message has to be parsed, which is automatically localized by the OS.

I see two possible fixes for this:

  • Retry on every FileNotFoundException, which also delays failures when the pipe doesn't exist
  • Somehow find a way to call the FormatMessage() Windows API function to get the localized error string for ERROR_PIPE_BUSY and compare that with the exception message
Comment by Diego Dupin [ 2017-02-23 ]

Hi philipp.

Right, ERROR_PIPE_BUSY cannot be handle properly in java (without access to native implementation of WaitNamedPipe method).
Only solution is to retry, using a specific timeout.

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