-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Milestone
Description
Expected Behavior
Remove spinlock for used by RedisLockRegistry
So, I thought about how to improve this part through redis pub-sub.
Current Behavior
Currently, spinlock is used to acquire redis-lock.
while (!obtainLock()) {
Thread.sleep(100); //NOSONAR
}
long expire = now + TimeUnit.MILLISECONDS.convert(time, unit);
boolean acquired;
while (!(acquired = obtainLock()) && System.currentTimeMillis() < expire) { //NOSONAR
Thread.sleep(100); //NOSONAR
}
If a vm instance acquires a lock and persists for a long time, or if multiple vm instances try to acquire a lock, I think the part where obtainLock() is called continuously is wasteful.
Context
I would like to contribute to the project.
If it's okay with you, I'd like to write a PR and get a review.