Skip to content

Commit

Permalink
fix(lock): delete redis subservice lock if the refresh or release fai…
Browse files Browse the repository at this point in the history
…led (#617)
  • Loading branch information
michaelmass authored Aug 31, 2023
1 parent 15546ec commit 78f978a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/engine/src/distributed/redis/subservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class RedisSubservice implements DistributedSubservice {
void this.refresh(ressource)
}, DEFAULT_LOCK_TTL / 6)
} catch (e) {
delete this.locks[ressource]
this.logger.error(e, `Failed to extend lock ${ressource}`)
}
}
Expand All @@ -176,7 +177,10 @@ export class RedisSubservice implements DistributedSubservice {
clearTimeout(lock.timeout)
}

await this.redlock.release(lock.lock)
await this.redlock.release(lock.lock).catch((e: Error) => {
this.logger.error(e, `Failed to release lock ${lock.ressource}`)
})

delete this.locks[lock.ressource]
}

Expand Down

0 comments on commit 78f978a

Please sign in to comment.