Skip to content

[Lock] "NOSCRIPT No matching script. Please use EVAL." after updating to symfony/lock 7.2.3 #59686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
acelaya opened this issue Feb 4, 2025 · 2 comments · Fixed by #59661
Closed

Comments

@acelaya
Copy link

acelaya commented Feb 4, 2025

Symfony version(s) affected

7.2.3

Description

Using symfony/lock's RedisStore with a predis Client, can randomly throw a Predis\Response\ServerException with the message NOSCRIPT No matching script. Please use EVAL. when trying to create a lock.

I haven't been able to reproduce it consistently, as it seems it can sometimes get solved by restarting the redis server.

This didn't happen with v7.2.0, only with v7.2.3, and by looking at the diff, I see things are being handled differently for this particular error, so I guess those changes are related.

How to reproduce

Create a folder with the following files:

docker-compose.yml

services:
    redis:
        image: redis:7.4-alpine
        ports:
            - "6381:6379"

composer.json

{
    "name": "acelaya/symfony-lock-error-repro",
    "type": "project",
    "require": {
        "symfony/lock": "7.2.3",
        "predis/predis": "^2.3"
    }
}

index.php

<?php

declare(strict_types=1);

use Predis\Client;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\RedisStore;

require __DIR__ . '/vendor/autoload.php';

$predisClient = new Client('tcp://127.0.0.1:6381');
$lockStore = new RedisStore($predisClient);
$lockFactory = new LockFactory($lockStore);

$lock = $lockFactory->createLock('test');
$lock->acquire();
$lock->release();

Then run the following commands:

  1. docker compose up -d
  2. composer install
  3. php index.php

You will see the following error:

PHP Fatal error:  Uncaught Predis\Response\ServerException: NOSCRIPT No matching script. Please use EVAL. in /symfony-lock-error/symfony-lock/vendor/predis/predis/src/Client.php:416
Stack trace:
#0 /symfony-lock-error/symfony-lock/vendor/predis/predis/src/Client.php(385): Predis\Client->onErrorResponse()
#1 /symfony-lock-error/symfony-lock/vendor/predis/predis/src/Client.php(335): Predis\Client->executeCommand()
#2 /symfony-lock-error/symfony-lock/vendor/symfony/lock/Store/RedisStore.php(287): Predis\Client->__call()
#3 /symfony-lock-error/symfony-lock/vendor/symfony/lock/Store/RedisStore.php(200): Symfony\Component\Lock\Store\RedisStore->evaluate()
#4 /symfony-lock-error/symfony-lock/vendor/symfony/lock/Lock.php(218): Symfony\Component\Lock\Store\RedisStore->delete()
#5 /symfony-lock-error/symfony-lock/index.php(16): Symfony\Component\Lock\Lock->release()
#6 {main}

Next Symfony\Component\Lock\Exception\LockReleasingException: Failed to release the "test" lock. in /symfony-lock-error/symfony-lock/vendor/symfony/lock/Lock.php:223
Stack trace:
#0 /symfony-lock-error/symfony-lock/index.php(16): Symfony\Component\Lock\Lock->release()
#1 {main}
  thrown in /symfony-lock-error/symfony-lock/vendor/symfony/lock/Lock.php on line 223

If you update the composer.json like this

{
    "name": "acelaya/symfony-lock-error-repro",
    "type": "project",
    "require": {
-        "symfony/lock": "7.2.3",
+        "symfony/lock": "7.2.0",
        "predis/predis": "^2.3"
    }
}

Then run composer update and then php index.php, you'll experience no such error.

Possible Solution

Downgrading to symfony/lock 7.2.0 seems to work around the issue for now

Additional Context

For context, this was first reported here shlinkio/shlink#2350

@xabbuh
Copy link
Member

xabbuh commented Feb 4, 2025

Can you please test if #59661 would solve this issue?

@acelaya
Copy link
Author

acelaya commented Feb 4, 2025

Can you please test if #59661 would solve this issue?

Yep! It works, both for the minimum reproduction I shared above and the actual project.

@xabbuh xabbuh linked a pull request Feb 4, 2025 that will close this issue
nicolas-grekas added a commit that referenced this issue Feb 4, 2025
This PR was merged into the 7.2 branch.

Discussion
----------

[Lock] Fix Predis error handling

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #59686
| License       | MIT

#59348 completely broke the Redis store when used with a service, eg:

```yaml
framework:
  lock:
    resources:
      default: snc_redis.default
```

The assumption that `exceptions` is always `false` is only correct when a DSN is used.

Commits
-------

b20892f [Lock] Fix Predis error handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants