Fixed a bunch of MySQL pooling issues where connections were not properly released or were double-released

This commit is contained in:
Andris Reinman 2016-04-05 15:29:42 +03:00
parent 06d2712916
commit 0392473ecd
8 changed files with 10 additions and 13 deletions

View file

@ -313,8 +313,8 @@ module.exports.send = (id, callback) => {
// campaigns marked as status=2 should be picked up by the sending processes
connection.query('UPDATE campaigns SET `status`=2, `status_change`=NOW() WHERE id=? LIMIT 1', [id], err => {
connection.release();
if (err) {
connection.release();
return callback(err);
}
return callback(null, true);
@ -453,11 +453,10 @@ module.exports.findMail = (responseId, callback) => {
if (err || !rows || !rows.length) {
return checkNext();
}
connection.release();
let message = rows[0];
message.campaign = campaign.id;
connection.release();
return callback(null, message);
});
};
@ -482,7 +481,6 @@ function createCampaignTables(id, callback) {
connection.query(query, err => {
connection.release();
if (err) {
return callback(err);
}
return callback(null, true);