mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 21:58:02 +01:00
Fix for jedis pool deadlock
1) Remove nested pool checkouts 2) Add a max wait so it won't block forever on deadlock
This commit is contained in:
@@ -39,19 +39,27 @@ public class LuaScript {
|
||||
|
||||
public Object execute(List<byte[]> keys, List<byte[]> args) {
|
||||
try (Jedis jedis = jedisPool.getWriteResource()) {
|
||||
try {
|
||||
return jedis.evalsha(sha, keys, args);
|
||||
} catch (JedisDataException e) {
|
||||
storeScript(jedisPool, script);
|
||||
return jedis.evalsha(sha, keys, args);
|
||||
}
|
||||
return execute(jedis, keys, args);
|
||||
}
|
||||
}
|
||||
|
||||
public Object execute(Jedis jedis, List<byte[]> keys, List<byte[]> args) {
|
||||
try {
|
||||
return jedis.evalsha(sha, keys, args);
|
||||
} catch (JedisDataException e) {
|
||||
storeScript(jedis, script);
|
||||
return jedis.evalsha(sha, keys, args);
|
||||
}
|
||||
}
|
||||
|
||||
private String storeScript(ReplicatedJedisPool jedisPool, String script) {
|
||||
try (Jedis jedis = jedisPool.getWriteResource()) {
|
||||
return jedis.scriptLoad(script);
|
||||
return storeScript(jedis, script);
|
||||
}
|
||||
}
|
||||
|
||||
private String storeScript(Jedis jedis, String script) {
|
||||
return jedis.scriptLoad(script);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user