polina-suzdal / symfony-discusion

0 stars 0 forks source link

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

Open polina-suzdal opened 1 year ago

polina-suzdal commented 1 year ago

Symfony version(s) affected 6.2.3

Description https://github.com/symfony/symfony/pull/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 https://github.com/symfony/symfony/pull/48711:

              @$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

powernic commented 1 year ago

Or try 6.2.3 which was released some hours ago.

Feedback welcome 🤗

powernic commented 1 year ago

Symfony version(s) affected 6.2.3

Description symfony/symfony#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 symfony/symfony#48711:

              @$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

Best regards

Your fan

polina-suzdal commented 1 year ago

Or try 6.2.3 which was released some hours ago.

Feedback welcome 🤗 @powernic thx

chalasr commented 1 year ago

See https://github.com/symfony/symfony/pull/48813