Skip to content

[Cache] Redis connection failed: Redis server went away #48813

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
ThomasTr opened this issue Dec 28, 2022 · 8 comments
Closed

[Cache] Redis connection failed: Redis server went away #48813

ThomasTr opened this issue Dec 28, 2022 · 8 comments

Comments

@ThomasTr
Copy link
Contributor

ThomasTr commented Dec 28, 2022

Symfony version(s) affected

6.2.3

Description

Pull request 48711 breaks symfony/cache with Redis at least for me

How to reproduce

Update symfony from 6.2.2 to 6.2.3

I have set this REDIS_PROVIDER=redis://localhost/2 in my .env, after Upgrade to 6.2.3 i get the error:
Redis connection "redis://localhost/2" failed: Redis server went away. Revert to 6.2.2 and everything works again.

When i revert the change from row 222 of this pull request:

              @$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') ? [[
                        'auth' => $params['auth'] ?? '',
                        'stream' => $params['ssl'] ?? null,
                    ]] : []);

back to before pull request:

                    @$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') ? [['stream' => $params['ssl'] ?? null]] : []);

everything works again.

The value of Redis::SCAN_PREFIX is (int) 2

And the content of the last array is

array(1) {
  [0]=>
  array(2) {
    ["auth"]=>
    string(0) ""
    ["stream"]=>
    NULL
  }
}

For me it works only, when this array is empty.

And this is the content of $params:


array(16) {
  ["scheme"]=>
  string(4) "file"
  ["host"]=>
  string(9) "localhost"
  ["path"]=>
  string(0) ""
  ["dbindex"]=>
  string(1) "2"
  ["lazy"]=>
  bool(true)
  ["class"]=>
  NULL
  ["persistent"]=>
  int(0)
  ["persistent_id"]=>
  NULL
  ["timeout"]=>
  int(30)
  ["read_timeout"]=>
  int(0)
  ["retry_interval"]=>
  int(0)
  ["tcp_keepalive"]=>
  int(0)
  ["redis_cluster"]=>
  bool(false)
  ["redis_sentinel"]=>
  NULL
  ["failover"]=>
  string(4) "none"
  ["ssl"]=>
  NULL
}

Trace Stack:

Symfony\Component\Cache\Exception\InvalidArgumentException:
Redis connection "redis://localhost/2" failed: Redis server went away

  at vendor/symfony/cache/Traits/RedisTrait.php:250
  at Symfony\Component\Cache\Adapter\RedisAdapter::Symfony\Component\Cache\Traits\{closure}()
     (vendor/symfony/var-exporter/LazyProxyTrait.php:101)
  at Symfony\Component\Cache\Traits\Redis5Proxy->__get('lazyObjectReal')
     (vendor/symfony/cache/Traits/Redis5Proxy.php:294)
  at Symfony\Component\Cache\Traits\Redis5Proxy->get('sf_su2l92fttpf0cmiqbeo34b4vppm')
     (vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php:55)
  at Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler->doRead('u2l92fttpf0cmiqbeo34b4vppm')
     (vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php:69)
  at Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler->read('u2l92fttpf0cmiqbeo34b4vppm')
     (vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php:49)
  at Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler->validateId('u2l92fttpf0cmiqbeo34b4vppm')
     (vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php:69)
  at Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy->validateId('u2l92fttpf0cmiqbeo34b4vppm')
  at session_start()
     (vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:172)
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
     (vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:296)
  at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')
     (vendor/symfony/http-foundation/Session/Session.php:201)
  at Symfony\Component\HttpFoundation\Session\Session->getBag('attributes')
     (vendor/symfony/http-foundation/Session/Session.php:221)
  at Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
     (vendor/symfony/http-foundation/Session/Session.php:69)
  at Symfony\Component\HttpFoundation\Session\Session->get('_security_main')
     (vendor/symfony/security-http/Firewall/ContextListener.php:98)
  at Symfony\Component\Security\Http\Firewall\ContextListener->authenticate(object(RequestEvent))
     (vendor/symfony/security-bundle/Debug/WrappedLazyListener.php:46)
  at Symfony\Bundle\SecurityBundle\Debug\WrappedLazyListener->authenticate(object(RequestEvent))
     (vendor/symfony/security-bundle/Security/LazyFirewallContext.php:60)
  at Symfony\Bundle\SecurityBundle\Security\LazyFirewallContext->__invoke(object(RequestEvent))
     (vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php:70)
  at Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener->callListeners(object(RequestEvent), object(Generator))
     (vendor/symfony/security-http/Firewall.php:92)
  at Symfony\Component\Security\Http\Firewall->onKernelRequest(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:206)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(RequestEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:56)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(RequestEvent), 'kernel.request')
     (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:127)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(RequestEvent), 'kernel.request')
     (vendor/symfony/http-kernel/HttpKernel.php:139)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:74)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:184)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:20)
  at require('/Users/tom/Projects/app4/public/index.php')
     (/Users/tom/.composer/vendor/laravel/valet/server.php:234)                ```


### Possible Solution

_No response_

### Additional Context

_No response_
@gignonje
Copy link

Same issue with update from symfony/cache: 5.4.15 to symfony/cache 5.4.17.

[cache] Failed to save key "(...)" of type string: Redis connection "redis://redis:6379" failed: . ["key" => "(...)","exception" => Symfony\Component\Cache\Exception\InvalidArgumentException^ { …},"cache-adapter" => "Symfony\Component\Cache\Adapter\RedisAdapter"]

Reverting changes like above fixes it.

@rikvdh
Copy link
Contributor

rikvdh commented Dec 28, 2022

6.2.3 is also broken for me. Connection without authentication cannot be established anymore. the 'auth' context now defaults to an empty string which tries to authenticate to Redis with an empty authentication string. When having authentication disabled this now fails. Removing this line seems to fix it:

'auth' => $params['auth'] ?? '',

the auth part needs to be fully gone in order to work without authentication in Redis.

@juceda
Copy link

juceda commented Dec 28, 2022

For me too..... I'm using UNIX socket.

{"message":"Failed to save key "test_key" of type array: Redis connection "redis:///var/redis/redis.sock" failed: Redis server went away","context":{"key":"test_key","exception":{"class":"Symfony\Component\Cache\Exception\InvalidArgumentException","message":"Redis connection "redis:///var/redis/redis.sock" failed: Redis server went away","code":0,"file":"vendor/symfony/cache/Traits/RedisTrait.php:244"},"cache-adapter":"Symfony\Component\Cache\Adapter\RedisTagAwareAdapter"},"level":300,"level_name":"WARNING","channel":"cache","datetime":"2022-12-28T18:41:22.134825+01:00","extra":{}}

@gndk
Copy link
Contributor

gndk commented Dec 28, 2022

Same issue upgrading from 6.2.2 to 6.2.3. GitLab CI job with Redis service in default configuration (no auth) suddenly failed.

In RedisTrait.php line 244:
                                                                        
  Redis connection "redis://redis:6379" failed: Redis server went away

@ToshY
Copy link
Contributor

ToshY commented Dec 29, 2022

This also impacts me on 6.1.9.

@nicolas-grekas Could you please take a look at this?

Because it has also been merged back into 6.1.9, 6.0.17 and 5.4.17 it's going to impact quite a lot of people 🙁

@michaljusiega
Copy link
Contributor

Same issue after updating from 6.2.2 to 6.2.3

chalasr added a commit that referenced this issue Dec 29, 2022
* 5.4:
  fix for caching without auth parameter, broken by #48711, fix for #48813
  Bump Symfony version to 5.4.18
  Update VERSION for 5.4.17
  Update CONTRIBUTORS for 5.4.17
  Update CHANGELOG for 5.4.17
chalasr added a commit that referenced this issue Dec 29, 2022
* 6.0:
  fix for caching without auth parameter, broken by #48711, fix for #48813
  Bump Symfony version to 6.0.18
  Update VERSION for 6.0.17
  Update CHANGELOG for 6.0.17
  Bump Symfony version to 5.4.18
  Update VERSION for 5.4.17
  Update CONTRIBUTORS for 5.4.17
  Update CHANGELOG for 5.4.17
@dcorto
Copy link

dcorto commented Dec 29, 2022

Same issue after updating from 6.0.16 to 6.0.17

chalasr added a commit that referenced this issue Dec 29, 2022
* 6.1:
  fix for caching without auth parameter, broken by #48711, fix for #48813
  Bump Symfony version to 6.1.10
  Update VERSION for 6.1.9
  Update CHANGELOG for 6.1.9
  Bump Symfony version to 6.0.18
  Update VERSION for 6.0.17
  Update CHANGELOG for 6.0.17
  Bump Symfony version to 5.4.18
  Update VERSION for 5.4.17
  Update CONTRIBUTORS for 5.4.17
  Update CHANGELOG for 5.4.17
chalasr added a commit that referenced this issue Dec 29, 2022
* 6.2:
  fix for caching without auth parameter, broken by #48711, fix for #48813
  Bump Symfony version to 6.2.4
  Update VERSION for 6.2.3
  Update CHANGELOG for 6.2.3
  Bump Symfony version to 6.1.10
  Update VERSION for 6.1.9
  Update CHANGELOG for 6.1.9
  Bump Symfony version to 6.0.18
  Update VERSION for 6.0.17
  Update CHANGELOG for 6.0.17
  Bump Symfony version to 5.4.18
  Update VERSION for 5.4.17
  Update CONTRIBUTORS for 5.4.17
  Update CHANGELOG for 5.4.17
  [DependencyInjection] Fix resolving parameters when dumping lazy proxies
@chalasr
Copy link
Member

chalasr commented Dec 29, 2022

Fixed in #48816.

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

No branches or pull requests

10 participants