ITADN

Pool timeout error with minimumIdle = 0

#331Openn0v1 创建于 2025-09-17
N
n0v1commented
Hello there, I noticed an unexpected behaviour in mariadb version 3.4.5: When setting minimumIdle to 0, a pool timeout error is thrown after acquireTimeout is reached. Reproduction: ```javascript const mariadb = require('mariadb') const pool = mariadb.createPool({ host : 'localhost', port : 3306, user : 'test', password : 'test', database : 'test', minimumIdle : 0, acquireTimeout : 5 * 1000, }) const main = async () => { try { await pool.query('SELECT SLEEP(0.5)') } finally { await pool.end() } } main() .then(() => console.log('done')) .catch(err => console.error(err)) ``` When not setting minimumIdle or when setting it to a positive value this works as expected but when setting it to 0, it logs this error: ``` SqlError: (conn:-1, no: 45028, SQLState: HY000) pool timeout: failed to retrieve a connection from pool after 5004ms (pool connections: active=0 idle=0 limit=10) at module.exports.createError (/home/me/test/node_modules/.pnpm/mariadb@3.4.5/node_modules/mariadb/lib/misc/errors.js:66:10) at Pool._rejectTimedOutRequest (/home/me/test/node_modules/.pnpm/mariadb@3.4.5/node_modules/mariadb/lib/pool.js:347:33) at Pool._checkRequestTimeouts (/home/me/test/node_modules/.pnpm/mariadb@3.4.5/node_modules/mariadb/lib/pool.js:315:14) at listOnTimeout (node:internal/timers:588:17) at process.processTimers (node:internal/timers:523:7) { sqlMessage: 'pool timeout: failed to retrieve a connection from pool after 5004ms\n' + ' (pool connections: active=0 idle=0 limit=10)', sql: null, fatal: false, errno: 45028, sqlState: 'HY000', code: 'ER_GET_CONNECTION_TIMEOUT' } ``` Even with no idle connections auto-created on pool instanciation (minimumIdle: 0) I would expect the query to work. I think this happens because of check `this.#idleConnections.length < this.opts.minimumIdle` in _shouldCreateMoreConnections() (see https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/3.4.5/lib/pool.js#L472). Is this expected behaviour or a bug?
0 条评论