mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 03:48:05 +01:00
Fixed a potential issue where locks could get out of sync between Redis instances.
This commit is contained in:
committed by
Jon Chambers
parent
251364d8be
commit
1b5dc0e434
@@ -56,7 +56,11 @@ public class LockingRateLimiter extends RateLimiter {
|
||||
final String lockName = getLockName(key);
|
||||
|
||||
final boolean acquiredLock = jedis.set(lockName, "L", "NX", "EX", 10) != null;
|
||||
cacheCluster.useWriteCluster(connection -> connection.async().set(lockName, "L", SetArgs.Builder.nx().ex(10)));
|
||||
|
||||
if (acquiredLock) {
|
||||
// TODO Restore the NX flag when the cluster becomes the primary source of truth
|
||||
cacheCluster.useWriteCluster(connection -> connection.async().set(lockName, "L", SetArgs.Builder.ex(10)));
|
||||
}
|
||||
|
||||
return acquiredLock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user