Skip to content

Pool not releasing connections if maxIdle is not set #2493

Open
@danj1980

Description

@danj1980

All of my queries include dbConnection.release(), however the connections do not get released and once connectionLimit is reached, the execution pauses waiting for an available connection.

I've re-worked my code so that every pool.getConnection() has a dbConnection.release() right next to it, to make absolutely certain that I'm not accidentally leaving any connections unreleased.

However, this did not help, and it seems that there is a bug in the releasing of pool connections.

I store my pool in a static variable with a class called Global.

class globals
{
	static dbPool = null;
}

Runs once on startup

		globals.dbPool = await mysql.createPool({
				host: databaseServer,
				port: databasePort,
				user: databaseUsername,
				password: databasePassword,
				database: databaseName,
				connectionLimit: 10
			});

Example usage

        const dbConnection = await globals.dbPool.getConnection();

        let mysqlResponse = null;

        await dbConnection.query(`SELECT * FROM guild;`).then(result => {
            mysqlResponse = result[0];

        }).catch(err => console.log(err));

        dbConnection.release();
Result after some queries have been executed 
![image](https://github.com/sidorares/node-mysql2/assets/12071228/17c7aca3-567e-4202-8ebe-b202fcba6c5d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions