From dfa1db1432d5fd075127cf4aa67003b91aecee45 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 5 Mar 2024 07:44:07 +0100 Subject: [PATCH 1/4] feat: refs #5846 Added eventScheduler function --- myt-push.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/myt-push.js b/myt-push.js index 970fc7b..77c3b9c 100644 --- a/myt-push.js +++ b/myt-push.js @@ -225,6 +225,7 @@ class Push extends Command { // Apply versions this.emit('applyingVersions'); + await this.eventScheduler(false); let nVersions = 0; let nChanges = 0; @@ -342,6 +343,7 @@ class Push extends Command { await conn.query('FLUSH PRIVILEGES'); await conn.query(`DROP TEMPORARY TABLE tProcsPriv`); } + await this.eventScheduler(true); } for (const change of changes) @@ -533,6 +535,12 @@ class Push extends Command { return a.path.localeCompare(b.path); }); } + + async eventScheduler(isActive) { + await conn.query( + `SET GLOBAL event_scheduler = ${isActive ? 'ON' : 'OFF'}` + ); + } } const typeMap = { -- 2.40.1 From 7d68eaa3ac148d8c3884e68a6f365a24eed5f2f9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 11 Mar 2024 09:25:43 +0100 Subject: [PATCH 2/4] feat: refs #5846 Requested changes --- myt-push.js | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/myt-push.js b/myt-push.js index 77c3b9c..34a9a81 100644 --- a/myt-push.js +++ b/myt-push.js @@ -156,11 +156,19 @@ class Push extends Command { 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'}` + ); + } + async function releaseLock() { await conn.query(`DO RELEASE_LOCK('myt_push')`); + await eventScheduler(true); } try { + await eventScheduler(false); await this.push(myt, opts, conn); } catch(err) { try { @@ -225,7 +233,6 @@ class Push extends Command { // Apply versions this.emit('applyingVersions'); - await this.eventScheduler(false); let nVersions = 0; let nChanges = 0; @@ -343,7 +350,6 @@ class Push extends Command { await conn.query('FLUSH PRIVILEGES'); await conn.query(`DROP TEMPORARY TABLE tProcsPriv`); } - await this.eventScheduler(true); } for (const change of changes) @@ -535,12 +541,6 @@ class Push extends Command { return a.path.localeCompare(b.path); }); } - - async eventScheduler(isActive) { - await conn.query( - `SET GLOBAL event_scheduler = ${isActive ? 'ON' : 'OFF'}` - ); - } } const typeMap = { diff --git a/package.json b/package.json index ff7d358..8171d65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@verdnatura/myt", - "version": "1.6.8", + "version": "1.6.9", "author": "Verdnatura Levante SL", "description": "MySQL version control", "license": "GPL-3.0", -- 2.40.1 From 823de4889f986faa807d052b68f4e6c972aa5c19 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 11 Mar 2024 13:05:40 +0100 Subject: [PATCH 3/4] 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 { -- 2.40.1 From 3324175483a393088c3f5edfe8fe10df74114f6a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 20 Mar 2024 12:20:10 +0100 Subject: [PATCH 4/4] feat: refs #5846 Requested changes --- myt-push.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/myt-push.js b/myt-push.js index 2c3e447..041baf7 100644 --- a/myt-push.js +++ b/myt-push.js @@ -133,9 +133,6 @@ 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( @@ -156,10 +153,12 @@ 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}`); } + const [[scheduler]] = await conn.query(`SELECT @@event_scheduler state`); + if (scheduler.state === 'ON') await eventScheduler(false); + async function eventScheduler(isActive) { await conn.query( `SET GLOBAL event_scheduler = ${isActive ? 'ON' : 'OFF'}` @@ -167,8 +166,8 @@ class Push extends Command { } async function releaseLock() { - await conn.query(`DO RELEASE_LOCK('myt_push')`); if (scheduler.state === 'ON') await eventScheduler(true); + await conn.query(`DO RELEASE_LOCK('myt_push')`); } try { -- 2.40.1