node-redlock
node-redlock copied to clipboard
How to distinguish between initial quorom achievement and quorom renewal failures?
Hey,
Given the following code:
try {
return await this.redLock.using(resources, lockRenewalTime, options, fn);
} catch (err) {
// err is always "ExecutionError: The operation was unable to achieve a quorum during its retry window"
}
Given the signal provided to fn is aborted, and then an exception is thrown from the fn, it is then caught in the above catch block.
In that catch block, I cannot determine whether it was the initial quorom achievement that failed, or quorom renewal that failed during the running period of fn.
The err would always be:
error: ExecutionError: The operation was unable to achieve a quorum during its retry window.
at Redlock._execute (/usr/src/app/node_modules/redlock/dist/cjs/index.js:296:23)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Redlock.using (/usr/src/app/node_modules/redlock/dist/cjs/index.js:474:13)
at async LockManager.using (/usr/src/app/src/services/lock-manager.js:37:14)
I need that in order to decide on the subsequent behavior. The initial quorom is a much softer error, while the latter one is something I have to handle differently.
Thanks for the help
This would also help me with some diagnostics :-)