Throw errors on lock not executed

This commit is contained in:
Adria Navarro 2024-03-05 23:33:20 +01:00
parent 0a2fb4a3a6
commit 3dbf0b3a64
1 changed files with 12 additions and 3 deletions

View File

@ -24,7 +24,16 @@ interface ProcessDocMessage {
}
export const docWritethroughProcessorQueue = createQueue<ProcessDocMessage>(
JobQueue.DOC_WRITETHROUGH_QUEUE
JobQueue.DOC_WRITETHROUGH_QUEUE,
{
jobOptions: {
attempts: 5,
backoff: {
type: "fixed",
delay: 1000,
},
},
}
)
docWritethroughProcessorQueue.process(async message => {
@ -41,7 +50,7 @@ docWritethroughProcessorQueue.process(async message => {
const lockResponse = await locks.doWithLock(
{
type: LockType.TRY_ONCE,
type: LockType.TRY_TWICE,
name: LockName.PERSIST_WRITETHROUGH,
resource: cacheKeyPrefix,
ttl: Duration.fromSeconds(60).toMs(),
@ -61,7 +70,7 @@ docWritethroughProcessorQueue.process(async message => {
)
if (!lockResponse.executed) {
console.log(`Ignoring redlock conflict in write-through cache`)
throw new Error(`Ignoring redlock conflict in write-through cache`)
}
})