Unable to lock multi resources in cluster mode
See original GitHub issuenode-relock version: 4.1.0 ioredis version: 4.14.1
Hi, I’m trying to use node-redlock with redis-cluster. When locking multi resources, I got a “LockError” exception. It exceeds the 10 attempts to lock.
Here’s my code
let client = new redis.Cluster([
{
ip: '127.0.0.1',
port: '7001'
},
{
ip: '127.0.0.1',
port: '7002'
},
{
ip: '127.0.0.1',
port: '7003'
}
])
let lk = new redlock([client])
let l = null
l = await lk.lock(['lk1', 'lk2'], 1000) //failure
//l = await lk.lock(['lk'], 1000) //success
let res = await client.get('foo')
(node:28707) UnhandledPromiseRejectionWarning: LockError: Exceeded 10 attempts to lock the resource "lk1,lk2".
at /home/sx/projects/nodejs/njproj1/node_modules/redlock/redlock.js:411:20
at tryCatcher (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/util.js:16:23)
at Promise.errorAdapter [as _rejectionHandler0] (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/nodeify.js:35:34)
at Promise._settlePromise (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/promise.js:601:21)
at Promise._settlePromise0 (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/promise.js:725:18)
at _drainQueueStep (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/home/sx/projects/nodejs/njproj1/node_modules/bluebird/js/release/async.js:15:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (2 by maintainers)
Top Results From Across the Web
Developers - Unable to lock multi resources in cluster mode -
Hi, I'm trying to use node-redlock with redis-cluster. When locking multi resources, I got a "LockError" exception. It exceeds the 10 attempts to...
Read more >7.4. Enabling, Disabling, and Banning Cluster Resources
You can manually stop a running resource and prevent the cluster from starting it again with the following command. Depending on the rest...
Read more >Resolve blocking problem caused by lock escalation - SQL ...
The SQL Server can't obtain a LOCK resource at this time. Rerun your statement when there are fewer active users or ask the...
Read more >Configuring and Managing Cluster Resources (Command Line)
To configure and manage cluster resources, either use the crm shell (crmsh) ... The crm command has several subcommands which manage resources, CIBs,...
Read more >Ubuntu Manpage: lvmlockd — LVM locking daemon
If the LV type prohibits shared access, such as a snapshot, the command will report an error and fail. The shared mode is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RuoFeng2015 @shonmorgun . I faced the same issue and going through the documentation revealed that the lock can only be applied to keys which have not been set yet. If you are trying to lock a key which is already redis db, then the lock execution will always fail. Try to run the same code with a new key.
You can find the info in attached screenshot on documentation for 4.2.0 on npmjs
This is still an issue guys