From 823de4889f986faa807d052b68f4e6c972aa5c19 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 11 Mar 2024 13:05:40 +0100 Subject: [PATCH] feat: refs #5846 Requested changes --- myt-push.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/myt-push.js b/myt-push.js index 34a9a81..2c3e447 100644 --- a/myt-push.js +++ b/myt-push.js @@ -133,6 +133,9 @@ class Push extends Command { if (opts.remote == 'local') opts.commit = true; + const [[scheduler]] = await conn.query(`SELECT @@event_scheduler state`); + if (scheduler.state === 'ON') await eventScheduler(false); + // Obtain exclusive lock const [[row]] = await conn.query( @@ -153,22 +156,22 @@ class Push extends Command { isUsed = row.isUsed; } + if (scheduler.state === 'ON') await eventScheduler(false); throw new Error(`Cannot obtain exclusive lock, used by connection ${isUsed}`); } async function eventScheduler(isActive) { - await conn.query( - `SET GLOBAL event_scheduler = ${isActive ? 'ON' : 'OFF'}` - ); + await conn.query( + `SET GLOBAL event_scheduler = ${isActive ? 'ON' : 'OFF'}` + ); } async function releaseLock() { await conn.query(`DO RELEASE_LOCK('myt_push')`); - await eventScheduler(true); + if (scheduler.state === 'ON') await eventScheduler(true); } try { - await eventScheduler(false); await this.push(myt, opts, conn); } catch(err) { try {