From 02a30adac0f92366ef9e6118581e39602b6d0d39 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 26 Jul 2017 21:15:29 +0200 Subject: catch deadlocks, fix failed msg passing --- worker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'worker.js') diff --git a/worker.js b/worker.js index 7af0e98..f68b848 100644 --- a/worker.js +++ b/worker.js @@ -225,6 +225,7 @@ amqp.connect(RABBITMQ_URI).then(async (rabbit) => { profiler = undefined; logger.info("processing batch", { + messages: msgs.size, players: player_data.size, matches: match_data.size }); @@ -282,7 +283,8 @@ amqp.connect(RABBITMQ_URI).then(async (rabbit) => { await ch.sendToQueue(ANALYZE_QUEUE, new Buffer(m.id), { persistent: true })); } catch (err) { - if (err instanceof Seq.TimeoutError) { + if (err instanceof Seq.TimeoutError || + (err instanceof Seq.DatabaseError && err.code == 1213)) { // deadlocks / timeout logger.error("SQL error", err); await Promise.map(msgs, async (m) => @@ -293,7 +295,7 @@ amqp.connect(RABBITMQ_URI).then(async (rabbit) => { await Promise.map(msgs, async (m) => { await ch.sendToQueue(QUEUE + "_failed", m.content, { persistent: true, - type: msg.properties.type, + type: m.properties.type, headers: m.properties.headers }); await ch.nack(m, false, false); -- cgit v1.3.1