Skip to content

Redis "parseConnectionConfigWithUrl" breaks clusters #28721

@Huggyduggy

Description

@Huggyduggy
  • Laravel Version: 5.8.20
  • PHP Version: 7.3.6
  • Database Driver & Version: phpredis 4.3.0

Disclaimer:

I sure hope I didn't miss any configuration change, I did my best at digging into it.

Description:

Starting with this commit c88de24 , redis configuration is parsed from URL, too. Afterwards, "driver" and "username" keys are removed from the array.

When using redis in cluster mode with phpredis, configuration looks as following (worked fine until updating today):

'redis' => [
'client' => 'phpredis',
'options' => [
'cluster' => 'redis',
],
'clusters' => [
'default' => [
[
'scheme' => env('REDIS_SCHEME', 'tcp'),
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DATABASE', 0),
],
],
],
],

Note that the default cluster is an array with a length of 1 (non-assoc. array, index 0). Therefore, when RedisManager calls parseConnectionConfiguration(), it receives [0 => array], rather than the config-array itself - with only 1 key (0)

God knows why, but in_array(0, ['driver', 'username']) yields true. The issue can be fixed by applying strict type checks: in_array($key, ['driver', 'username'], true). As a result, the [0 => array] $config array becomes empty ([]), and a "Must pass seeds" --> "Couldn't map cluster keyspace using any provided seed" is thrown.

As I haven't yet contributed to laravel (or any other open-source project) and I really don't want to mess with your time, I thought describing a possible fix might be quicker. I have not checked this possible solutions for side-effects.

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