From 3073397800b5704194ac570a5bd4707cb93e94be Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 29 Nov 2023 18:20:11 +0100 Subject: [PATCH] Fix ttl --- packages/backend-core/src/redis/redlockImpl.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/src/redis/redlockImpl.ts b/packages/backend-core/src/redis/redlockImpl.ts index cccb981399..048d17d080 100644 --- a/packages/backend-core/src/redis/redlockImpl.ts +++ b/packages/backend-core/src/redis/redlockImpl.ts @@ -111,14 +111,15 @@ export async function doWithLock( try { const name = getLockName(opts) - let ttl = opts.ttl || Duration.fromSeconds(15).toMs() + let ttl = opts.ttl || Duration.fromSeconds(30).toMs() // create the lock lock = await redlock.lock(name, ttl) if (!opts.ttl) { + // No TTL is provided, so we keep extending the lock while the task is running interval = setInterval(() => { - lock!.extend(ttl) + lock?.extend(ttl / 2) }, ttl / 2) }