node-redlock icon indicating copy to clipboard operation
node-redlock copied to clipboard

What is the key for redlock

Open Datta19 opened this issue 3 years ago • 3 comments
trafficstars

let lock = await redlock.acquire(["ABC123"], 5000);

in above code , if I give key which is not present in redis db then code works fine. if i give key which is present in redis db then code throw's an error. Please let me know what is the key it's key exist in the redis db or it's just any string identifier for locking.

Error:

(node:22592) UnhandledPromiseRejectionWarning: ExecutionError: The operation was unable to achieve a quorum during its retry window.

Datta19 avatar Aug 04 '22 04:08 Datta19

I think it works as expected. If you set the key in redis, that key won't get removed thus redlock cannot acquire that.

namchuai avatar Aug 22 '22 19:08 namchuai

"ABC123" is supposed to be the key for your lock, not for the resource you want to use. If 2 processes are trying to do the same thing when you only want a concurrency of 1, both processes should be using the same value for the lock key

andrhamm avatar Sep 29 '23 15:09 andrhamm