Redis server went away php

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Redis flushdb is causing error: «Redis server 127.0.0.1:6379 went away» #2312

Redis flushdb is causing error: «Redis server 127.0.0.1:6379 went away» #2312

Comments

Expected behaviour

Flushing the db using the phpredis function flushdb() should clear the redis database, and if a new redis call comes in to check if a key exists or to set a new key, it should respond null, false, or fail gracefully.

Actual behaviour

Instead the redis server is causing subsequent redis calls, to check if a key exists, or set a new key, to throw a redisException: «Redis server 127.0.0.1:6379 went away»

Note: It appears that the errors only happen during the few milliseconds that the database is being cleared and the server is resetting. Our site gets close to 80k uniques a day so this problem is probably not seen on sites will way less visitors. But on our site we get at least 1 or 2 exceptions every time we clear the cache during business hours, at night when traffic is way less, this error never happens. But, after those couple exceptions, everything goes back to normal, and no additional exceptions happen until the redis db is flushed again.

Читайте также:  Обнуление стилей css 2022

In addition, this error is new since we upgraded the server to php 8.1 and our wordpress code to 6.1. Before this upgrade the redis keys hovered around 500k keys, but after the update to wp 6.1 our keys have quadrupled to about 2 million. So while I understand that wordpress is now using redis more heavily in its core functions, and a DB with 2 million keys is going to take longer to flush, shouldn’t there be a way to make redis fail gracefully during this flushing process, instead of causing RedisExceptions.

I did add a php try/catch exception handler to the redis function that was causing the exception (in this first case, checking if a key exists). This worked for handling the exception for function. but then once that was handled the exceptions started firing on the setex() function. So it is just moving onto the next function after the exists() function returns null and is then trying to now set the key, and it is throwing the same exception on that function now.

Any help that you can give to reduce or eliminate these exceptions, would be greatly appreciated. thanks.

I’m seeing this behaviour on

  • OS: Ubuntu 20 (Linux 5.4.0-128-generic x86_64)
  • Redis: v7.0.5
  • PHP: v8.1.12
  • PhpRedis: v5.3.7

Steps to reproduce, backtrace or example script

See above, it happens every time I flush the db.

I’ve checked

  • [ X ] There is no similar issue from other users
  • [ X ] Issue isn’t fixed in develop branch

The text was updated successfully, but these errors were encountered:

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Redis server went away #374

Redis server went away #374

Comments

In continuation of #196 I reopen an issue as it is still happening.

When Xdebug is running, $redis->connect() throws a Redis server went away exception.

Читайте также:  Css сортировка по алфавиту

I’m running the latest Xdebug dev branch and tried with latest stable (2.2).
I’m also on the latest phpredis.

PHP 5.3.3-7+squeeze15 with Suhosin-Patch (cli) (built: Mar 4 2013 13:11:17) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.3.0dev, Copyright (c) 2002-2013, by Derick Rethans 

RedisException: Redis server went away

If I disable Xdebug, I don’t get the exception.

Workaround

At the moment I have to do this to get it working :

try < $redis->connect(); > catch (Exception $e)

Which is ugly. but makes it work.

The text was updated successfully, but these errors were encountered:

我遇到了这个,是因为我selinux 限制了apache访问网络,解决方法网上搜 jewdore.com

@mikespook Shouldn’t it just not throw an exception if we no previous connection was found?

Or should’nt it be called with

//Last arg set to 1 so that it doesn't throw redis_sock_get(object, &redis_sock TSRMLS_CC, 1)

(Last argument is noThrow)

Finally, I don’t see why xdebug would do not let you clear the exception

I think @Esya is correct that this should be called with the no_throw option set, from the context of redis_connect. We can throw the exception in the connect method itself.

I don’t believe it’s related to xdebug, as I use phpredis with xdebug myself, and don’t see this behavior. That being said, it could be something to do with the specific version of php and/or xdebug, so it is possibly where the issue is being caused.

I’ll take a look at the connect function and see if there are implications I’m not considering if we were to use the no_throw option.

I do get this exception even if xdebug is not installed. PHP 5.4.19

Have you tried 2.2.4? We changed how this works in the last release.

I am currently using 2.2.3, will upgrade to 2.2.4. Thank you so much for your help!

Also with 2.2.4 the problem persists. I also changed the timeouts. In my scenario two servers are accessing a third server where Redis is installed. Last time BOTH client had this issue at the same time, but the server logs show no trouble, only «Client closed connection».

So I’m a bit unclear on your issue. It seems like you’re just having connection issues in general, rather than ones related to a third party process capturing the exception that was previously thrown and then cancelled.

What happens if you just do this:

$obj_redis = new Redis(); var_dump($obj_redis->connect(, ));

I met the same question,and I «shutdown -r now» then it`s ok.

Читайте также:  Java operator cannot be applied to java lang string

Not sure if this helps, but i get this exception any time i run a command AFTER connecting.

$redis->setOption( 1, ‘1’ ); is giving me ‘Redis server went away’

Does phpredis return true or false from the connect call?

Now i feel silly. Thanks @michael-grunder. Figured that out

This is most likely a selinux problem. Try setenforce 0, if you got positive connection result use semanage port for fixing this task.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Redis server went away #196

Redis server went away #196

Comments

Env:
redis-server 2.4.1.4
phpredis 2.2.1
php 5.3.2-1
ubuntu 10.0.4

RedisException

Aways catch this exception, but can get data .

RedisException: Redis server went away in /var/www/redis.php on line 3

Call Stack:
0.0002 625328 1. () /var/www/redis.php:0
0.4026 626376 2. Redis->pconnect(string(9), long) /var/www/redis.php:3

Code

The text was updated successfully, but these errors were encountered:

I upgrade the php to 5.3.10 and close the xdebug extension , the Issue is resolved。

I’m glad you got it working. Have you tried it with php 5.3.10 and xdebug enabled? I’m not sure how xdebug would affect this, but I’m not overly familiar with the xdebug internals.

The problem is coming from Xdebug.

malletjo@malletjo:/data/test$ php -v

PHP 5.3.10-1ubuntu3.1 with Suhosin-Patch (cli) (built: May 4 2012 02:20:36)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

malletjo@malletjo:/data/test$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION=»Ubuntu 12.04 LTS»

malletjo@malletjo:/data/test$ cat redis.php

malletjo@malletjo:/data/test$ php -f redis.php
PHP RedisException: Redis server went away in /data/test/redis.php on line 4
PHP Stack trace:
PHP 1. () /data/test/redis.php:0
PHP 2. Redis->connect() /data/test/redis.php:4

malletjo@malletjo:/data/test$ php -f redis.php
YES

Источник

Оцените статью