GH-8730: Fix isAcquiredInThisProcess to use localLock
The `ExpirableLockRegistry.expireUnusedOlderThan()` uses a query to the target store by mistake. The logic of this API is indeed about the local cache for those lock instances. We cannot effect any other processes with this cache. And even if we remove our local instance while it is locked in other process, that doesn't mean that on the next `obtain()` call, when we got a fresh local instance, we will be able to acquire a lock in target store. * Fix `isAcquiredInThisProcess()` to check only `localLock.isLocked()` **Cherry-pick to `6.1.x` & `6.0.x`**
This commit is contained in:
@@ -55,6 +55,7 @@ import org.springframework.util.Assert;
|
||||
* @author Fran Aranda
|
||||
* @author Unseok Kim
|
||||
* @author Christian Tzolov
|
||||
* @author Myeonghyeon Lee
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
@@ -326,7 +327,7 @@ public class JdbcLockRegistry implements ExpirableLockRegistry, RenewableLockReg
|
||||
}
|
||||
|
||||
public boolean isAcquiredInThisProcess() {
|
||||
return this.mutex.isAcquired(this.path);
|
||||
return delegate.isLocked();
|
||||
}
|
||||
|
||||
public boolean renew() {
|
||||
|
||||
@@ -84,6 +84,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Anton Gabov
|
||||
* @author Christian Tzolov
|
||||
* @author Eddie Cho
|
||||
* @author Myeonghyeon Lee
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
@@ -514,8 +515,7 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl
|
||||
}
|
||||
|
||||
public final boolean isAcquiredInThisProcess() {
|
||||
return RedisLockRegistry.this.clientId.equals(
|
||||
RedisLockRegistry.this.redisTemplate.boundValueOps(this.lockKey).get());
|
||||
return this.localLock.isLocked();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user