title: mysql pool connection with node with the same connection acquired and released increasing on each call
body: <p>I have a node application connected to MySQL using <a href="https://github.com/mysqljs/mysql" rel="nofollow noreferrer">mysqljs/mysql</a>
  Recently I have realized this by debugging: (server logs)</p>
  <pre><code>info: Url: /loginWeb
  info: Method: POST
  info: Connection 1098089 acquired
  info: Connection 1098089 released
  POST /loginWeb 200 214.618 ms - 186
  info: Url: /loginWeb
  info: Method: POST
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 released
  info: Connection 1098089 released
  POST /loginWeb 200 76.776 ms - 186
  info: Url: /loginWeb
  info: Method: POST
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 released
  info: Connection 1098089 released
  info: Connection 1098089 released
  POST /loginWeb 200 122.202 ms - 186
  info: Url: /loginWeb
  info: Method: POST
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 released
  info: Connection 1098089 released
  info: Connection 1098089 released
  info: Connection 1098089 released
  POST /loginWeb 200 249.179 ms - 186
  info: Url: /loginWeb
  info: Method: POST
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 acquired
  info: Connection 1098089 released
  info: Connection 1098089 released
  info: Connection 1098089 released
  info: Connection 1098089 released
  info: Connection 1098089 released
  POST /loginWeb 200 101.805 ms - 186
  </code></pre>
  <p>As you can see in the logs, the same connection is acquired and released increasing on each call. I don't understand why.</p>
  <p>My code is this:</p>
  <pre><code>const mysql = require('mysql')
  const pool = mysql.createPool(config.mysql)
  
  exports.query = function (query, params, callback) {
    pool.getConnection(function (err, connection) {
      if (err) {
        log.error('getConnection -&gt; mysql connection error: ', err)
        throw err
      }
  
      connection.query(query, params, function (err, rows) {
        connection.release()
  
        if (!err) {
          callback(null, rows)
        }
      })
  
      connection.on('error', function (err) {
        connection.release()
        log.error('on error -&gt; mysql connection error: ', err)
        throw err
      })
    })
  
    pool.on('release', function (connection) {
      log.info('Connection %d released', connection.threadId)
    })
    pool.on('acquire', function (connection) {
      log.info('Connection %d acquired', connection.threadId)
    })
  }
  </code></pre>
  <p>NOTE: NodeJS can stablish the connection propertly but in a few minutes the connection is lost and DB returns: ECONTIMEOUT</p>
  <p>Can someone explain this behavior?</p>