Why some time do not work for all mysql session?

Until recently everything was fine. Now translated one module of a transaction, here is the code:

The module itself
socket.on('sell', async (id) => {
 try {
 id = parseInt(id, 10);

 if(!socket || !socket.userid) {

 if(!id) {

 let transaction = await connection.prepareTransaction();

 try {
 await transaction.beginTransaction();

 let item = await transaction.query('SELECT * FROM Items WHERE id = ? FOR UPDATE', [id]);

 if(!item || !item[0]) {
 await transaction.rollback();


 if(!item[0].userid) {
 await transaction.rollback();


 await transaction.query('UPDATE Items SET ? WHERE id = ?', [{status: 0, userid: null, timestamp: 0}, id]);

 await transaction.commit();
 } catch (e) {
 await transaction.rollback();
 } catch (error) {
 throw error;
mysql handler
const mysql = require('mysql');
const { promisify } = require('util');

const pool = mysql.createPool({
 host: config.host
 user: config.user
 password: config.password
 database: config.database
 socketPath: '/var/run/mysqld/mysqld.sock',
 connectionLimit: 100

exports.prepareTransaction = () => {
 return new Promise((resolve, reject) => {
 pool.getConnection((err, connection) => {
 if (err) throw err;

 const query = promisify(connection.query).bind(connection);
 const commit = promisify(connection.commit).bind(connection);
 const rollback = promisify(connection.rollback).bind(connection);
 const beginTransaction = promisify(connection.beginTransaction).bind(connection);
 const release = connection.release;

 resolve({beginTransaction, query, commit, rollback, release});

After a certain time (depending on user activity) mysql falling off, with it no error arrives. Only version - clogged all the available connections, because connection is not made.release(), but in my case it seems to be everywhere. Thus, when the connecting client is waiting for an available session, and it never has and never will.
After rebooting everything works fine again and after an hour or several hours, mysql drops again. Before the upgrade this was not.
June 7th 19 at 14:37
1 answer
June 7th 19 at 14:39
Promonitorte SHOW PROCESSLIST and htop within the hour, so You are sure to find out whether Your assumption.
htop I can only show the number of occupied memory and CPU load on the muscle, but I don't think 100 links will give something - Chyna.Anderson commented on June 7th 19 at 14:42
the possibility of dead lock You exclude? - Gonzalo.Hane39 commented on June 7th 19 at 14:45
at the time when you die queries in the application (apparently which are in constant expectation), PROCSSLIST shows:
And such processes a little more than 100 pieces.
After restart of the app they are just simply becomes:
And after that, the app works adequately 2-5 hours.
In htop I see these processes:
But they have no relationship to the work base, as I understand it. - Chyna.Anderson commented on June 7th 19 at 14:48
So You suggest that still there is some malfunction in the driver itself? Have you tried to replicate this same bug in a local environment? - Gonzalo.Hane39 commented on June 7th 19 at 14:51

Find more questions by tags MySQLNode.js