Bug #93841 Connection never acquired from a pool with a finite queueTimeout
Submitted: 7 Jan 2019 15:52 Modified: 13 Mar 2019 17:42
Reporter: Rui Quelhas Email Updates:
Status: Closed Impact on me:
None 
Category:Connector for Node.js Severity:S3 (Non-critical)
Version:8.0.13 OS:Any
Assigned to: Rui Quelhas CPU Architecture:Any
Tags: Connection, pool, queue, timeout

[7 Jan 2019 15:52] Rui Quelhas
Description:
As a user, I expect to be able to acquire new connections from a pool if old connections are being released before the queueTimeout is reached. Right now this seems to happen only for the scenario where queueTimeout is infinite (default behavior) but not for the case where it has a finite value.

How to repeat:
const client = mysqlx.getClient(config, { pooling: { enabled: true, maxSize: 1, queueTimeout: 2000 } });

return client.getSession()
  .then(session => {
    const delayed = new Promise(resolve => {
      setTimeout(() => session.close().then(resolve), 500);
    });

    return Promise.all([client.getSession(), delayed]);
  })
  .then(() => {
    return client.close() // is not reached but it should be
  })
  .catch(err => {
    console.log(err.message) // Could not retrieve a connection from the pool. Timeout of 2000 ms was exceeded.
  })

Suggested fix:
The client should retry to acquire the connection within the time gap defined by queueTimeout, preferably using some kind of backoff or sliding window.
[13 Mar 2019 17:42] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Node.js 8.0.16 release, and here's the changelog entry:

A queueTimeout value other than 0 (infinite) prevented the acquisition of
old released connections from the connection pool.

Thank you for the bug report.