I have a problem: I changed mysql from createConnection to createPool. But sometimes when many queries will run, I get deadlocks.
Here's the pool
var db_config = {
connectionLimit : 1000,
host: 'localhost',
user: '******',
password: '******',
database: '******.com'
};
pool = mysql.createPool(db_config);
pool.getConnection(function(err, connection) {
if(err) {
logger.error('[ERROR] Connecting to database "' + err.toString() + '"');
setTimeout(function() { database_connection(); }, 2500);
}
else
{
pool.query('SET NAMES utf8');
pool.query('SET CHARACTER SET utf8');
logger.trace('[INFO] Connected to database and set utf8!');
}
});
That's the database connection
But for any reason, when many queries send at same time or something, I get deadlock message
Deadlock found when trying to get lock; try restarting transaction
Every query that used for the queries looks like that
pool.query('SELECT * users');
I read that query combines connection + the query + release, that is what i read.
But I don't know why so much times deadlock... anyone has any ideas? :/
Its InnoDB MySQL Tables