feat: refs #5846 Added eventScheduler function #4

Merged
guillermo merged 4 commits from 5846-eventScheduler into master 2024-03-21 06:46:25 +00:00
1 changed files with 8 additions and 5 deletions
Showing only changes of commit 823de4889f - Show all commits

View File

@ -133,6 +133,9 @@ class Push extends Command {
if (opts.remote == 'local') if (opts.remote == 'local')
opts.commit = true; opts.commit = true;
const [[scheduler]] = await conn.query(`SELECT @@event_scheduler state`);
if (scheduler.state === 'ON') await eventScheduler(false);
guillermo marked this conversation as resolved Outdated
Outdated
Review

Mover a despues del GET_LOCK

Mover a despues del GET_LOCK
// Obtain exclusive lock // Obtain exclusive lock
const [[row]] = await conn.query( const [[row]] = await conn.query(
@ -153,22 +156,22 @@ class Push extends Command {
isUsed = row.isUsed; isUsed = row.isUsed;
} }
if (scheduler.state === 'ON') await eventScheduler(false);
throw new Error(`Cannot obtain exclusive lock, used by connection ${isUsed}`); throw new Error(`Cannot obtain exclusive lock, used by connection ${isUsed}`);
} }
async function eventScheduler(isActive) { async function eventScheduler(isActive) {
await conn.query( await conn.query(
`SET GLOBAL event_scheduler = ${isActive ? 'ON' : 'OFF'}` `SET GLOBAL event_scheduler = ${isActive ? 'ON' : 'OFF'}`
); );
} }
async function releaseLock() { async function releaseLock() {
await conn.query(`DO RELEASE_LOCK('myt_push')`); await conn.query(`DO RELEASE_LOCK('myt_push')`);
await eventScheduler(true); if (scheduler.state === 'ON') await eventScheduler(true);
guillermo marked this conversation as resolved Outdated
Outdated
Review

Mover antes del RELEASE_LOCK

Mover antes del RELEASE_LOCK
} }
try { try {
await eventScheduler(false);
await this.push(myt, opts, conn); await this.push(myt, opts, conn);
} catch(err) { } catch(err) {
try { try {