| Bug #101928 | ECONNREFUSED doesn't release connection back to pool | ||
|---|---|---|---|
| Submitted: | 9 Dec 2020 11:34 | Modified: | 9 Apr 2021 19:07 |
| Reporter: | Jen P | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector for Node.js | Severity: | S3 (Non-critical) |
| Version: | 8.0.22 | OS: | Any |
| Assigned to: | Rui Quelhas | CPU Architecture: | Any |
[9 Dec 2020 11:36]
Jen P
Suggested workaround:
const poolConfig = { pooling: { enabled: true, maxSize: 1, queueTimeout: 2000 } }
let pool = mysqlx.getClient(config, poolConfig)
let session = null
try {
session = await pool.getSession()
} catch (err) {
await pool.close()
pool = mysqlx.getClient(config, poolConfig)
}
[9 Apr 2021 19:07]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Connector/Node 8.0.24 release, and here's the proposed changelog entry from the documentation team: The getSession() method now executes release() if a getSession() exception is raised; as ot was not releasing the connection to the pool. Thank you for the bug report.

Description: I have set pooling to enabled and attempted to retrieve a session from the client. If I do this before mysql is ready then I get an ECONNREFUSED exception which is expected, but the connection never appears to be released. If the pool size is one then all subsequent attempts to getSession The exception is thrown from within the getSession method, so the session is not returned for me to call .end() manually. How to repeat: const mysqlx = require('@mysql/xdevapi'); const client = mysqlx.getClient(config, { pooling: { enabled: true, maxSize: 1, queueTimeout: 2000 } }); const session = await this.client.getSession(); // returns ECONNREFUSED exception /* wait for mysql to be ready and accepting connections */ const session = await this.client.getSession(); // returns connection pool queue timeout exception because the previous session hasn't been returned to the pool Suggested fix: Ensure release() method is called if an exception is raised during the getSession method.