Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] invalidating tags breaks after updating to symfony/cache 5.3.3 with Redis versions below 5.x #42126

Copy link
Copy link
Closed
@jordikroon

Description

@jordikroon
Issue body actions

symfony/cache: 5.3.3

Description
We are using a Redis version prior to Redis 5.x, Redis 3.2 to be precise. After upgrading the symfony/cache package to 5.3.3 we are experiencing a problem with flushing tags.

RedisException
ERR Error running script (call to f_cea3ea3b59f1b3411febbbeb5f94de8a695cec73): @user_script:19: @user_script: 19: Write commands not allowed after non deterministic commands. Call redis.replicate_commands() at the start of your script in order to switch to single commands replication mode.

How to reproduce

  • Upgrade symfony/cache to 5.3.3
  • Execute:
$redis = new \Redis();
$redis->connect($_ENV['REDIS_SERVER'], $_ENV['REDIS_PORT']);
$redis->select((int) $_ENV['REDIS_DATABASE']);

$cachePool = new RedisTagAwareAdapter($redis, 'cacheable');
$cachePool->invalidateTags($tags);

This will trigger an error.

Cannot use object of type RedisException as array

To reveal the real exception, add to symfony/cache/Adapter/RedisTagAwareAdapter.php:244 (after EOLUA;):

foreach ($results as $id => $values) {
  if ($values instanceof \RedisException) {
      throw $values;
  }
}

Possible Solution

In order to enable script effects replication, you need to issue the following Lua command before any write operated by the script:
redis.replicate_commands()
The function returns true if the script effects replication was enabled, otherwise if the function was called after the script already called some write command, it returns false, and normal whole script replication is used

Another possible solution is to update ext-redis requirements to 5.x. Though this will be a BC break

Additional context
https://redis.io/commands/eval#replicating-commands-instead-of-scripts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.