From a3ea15c1074ee3a3f3c7cb6c404a51dfced37330 Mon Sep 17 00:00:00 2001 From: Petrisor Ciprian Daniel Date: Thu, 10 Oct 2024 21:24:42 +0300 Subject: [PATCH] Fix script running for RedisCluster --- src/Symfony/Component/Lock/Store/RedisStore.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 09be11e4695c8..d530f56103a4c 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -237,7 +237,13 @@ private function evaluate(string $script, string $resource, array $args): mixed if (null !== ($err = $this->redis->getLastError()) && self::NO_SCRIPT_ERROR_MESSAGE === $err) { $this->redis->clearLastError(); - $this->redis->script('LOAD', $script); + if ($this->redis instanceof \RedisCluster) { + foreach ($this->redis->_masters() as $master) { + $this->redis->script($master, 'LOAD', $script); + } + } else { + $this->redis->script('LOAD', $script); + } if (null !== ($err = $this->redis->getLastError())) { throw new LockStorageException($err); @@ -260,7 +266,13 @@ private function evaluate(string $script, string $resource, array $args): mixed if (null !== ($err = $client->getLastError()) && self::NO_SCRIPT_ERROR_MESSAGE === $err) { $client->clearLastError(); - $client->script('LOAD', $script); + if ($this->redis instanceof \RedisCluster) { + foreach ($this->redis->_masters() as $master) { + $this->redis->script($master, 'LOAD', $script); + } + } else { + $this->redis->script('LOAD', $script); + } if (null !== ($err = $client->getLastError())) { throw new LockStorageException($err);