Skip to content

RedisCluster slot caching causes RedisClusterException on master change #2202

Open

Description

@Patrick-Remy

Expected behaviour

A manual or automatic cluster failover doesn't have any impact.

Actual behaviour

A cluster failover causes RedisClusterException: Couldn't map cluster keyspace using any provided seed for the first requests after (or during?) a cluster failover, if slot caching is enabled

I'm seeing this behaviour on

  • OS: debian
  • Redis: redis_version:6.2.7
  • PHP: 7.4.30
  • phpredis: how to get version? I think latest 5.3.7, as it's freshly built with pecl install redis.

Steps to reproduce, backtrace or example script

  1. Setup redis cluster
  2. Setup php-fpm with pooling static and only a few workers, e.g. in my setup start_servers=2 (important, otherwise not reproducible!)
  3. Configure session_save_path to use cluster with seed[]=10.x.x.x:6379&...&failover=error
  4. Add redis.clusters.cache_slots = 1 to a php.ini file.
  5. Open a php-page that uses session (and for me also writes some cache keys)
  6. Connect to a slave and master redis cluster node, of the same keyspace partition
  7. exec monitor and load your page, to ensure any write transactions (like setex from session) are done at your node
  8. do a cluster failover on the master
  9. immediately load your test page -> it will hang until timeout is reached and RedisClusterException: Couldn't map cluster keyspace using any provided seed is throwed

Sometimes it needs two attempts to reproduce it, then just failover back.

My connection script:

$connection = new RedisCluster(
           null,
           ['10.x.x.x:6379', ...]
           2,
           6,
           false,
           xxx
);

self::$connection->setOption(
            RedisCluster::OPT_SLAVE_FAILOVER,
            RedisCluster::FAILOVER_ERROR
);

// do some write transactions
$res = self::$connection->setex(
     $property,
    $expire,
    $value
);

Immediately after do not enabling slot caching, the error isn't reproducible anymore.

I've checked

  • There is no similar issue from other users (others are closed)
  • Issue isn't fixed in develop branch

Activity

  1. salkhwlani commented on May 15, 2023

    @salkhwlani

    the same issue here

  2. aKugler commented on Mar 31, 2025

    @aKugler

    I have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions