Reload scripts across the whole cluster if one shard is missing the script.

This commit is contained in:
Jon Chambers authored and Jon Chambers committed 2021-01-10 15:00:12 -05:00
1 parent 2d697ac8db
commit 1b53f10091
2 files changed
+22 -32

No files matched your search

@@ -64,7 +64,7 @@ public class ClusterLuaScript {
try {
return clusterCommands.evalsha(sha, scriptOutputType, keys.toArray(STRING_ARRAY), args.toArray(STRING_ARRAY));
} catch (final RedisNoScriptException e) {
clusterCommands.scriptLoad(script);
reloadScript();
return clusterCommands.evalsha(sha, scriptOutputType, keys.toArray(STRING_ARRAY), args.toArray(STRING_ARRAY));
}
} catch (final Exception e) {
@@ -82,7 +82,7 @@ public class ClusterLuaScript {
try {
return binaryCommands.evalsha(sha, scriptOutputType, keys.toArray(BYTE_ARRAY_ARRAY), args.toArray(BYTE_ARRAY_ARRAY));
} catch (final RedisNoScriptException e) {
binaryCommands.scriptLoad(script.getBytes(StandardCharsets.UTF_8));
reloadScript();
return binaryCommands.evalsha(sha, scriptOutputType, keys.toArray(BYTE_ARRAY_ARRAY), args.toArray(BYTE_ARRAY_ARRAY));
}
} catch (final Exception e) {
@@ -91,4 +91,8 @@ public class ClusterLuaScript {
}
});
}
private void reloadScript() {
redisCluster.useCluster(connection -> connection.sync().upstream().commands().scriptLoad(script));
}
}