mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 09:26:47 +00:00
Fixed a potential issue where locks could get out of sync between Redis instances.
This commit is contained in:
1 parent
251364d8be
commit
1b5dc0e434
1 file changed
+5
-1
+5
-1
@@ -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