-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
long running blpop crashes with Error while reading line from the server #74
Comments
This is most likely not a bug but just a misconfiguration, please follow these steps to make sure that both Redis and Predis are properly configured for long-idling connections and report back on this ticket if you still have problems. |
I can do this but I believe we should not do that, since this is a blocking call we can't do periodic pings to avoid being marked as idle http://php.net/manual/en/function.mysql-ping.php
in php-mysql an old mysql connection could be used, that connection could be timed-out or closed for many reasons so what Predis should do when it get connection reset or closed if we face this issue again while $_reconnecting===1 then we throw the error |
As a matter of fact, starting with Redis 2.6 the Anyway, if you still prefer to have a timeout set for idle connections then you can just do a PS: Predis won't support auto-reconnections since they are error prone and lead to unexpected behaviors in complex states such as MULTI / EXEC, pubsub or pipelines. |
I fear having stall connections on redis server living for ever which might lead to prevent it from accepting new connections because it reached maximum limit (if not in conf could be in kernel limit on max open connections per process)
we have another case when we do incremental indexing from our database into solr
note the way I suggest it, we don't get into infinite loop, because of the flag $_reconnecting=1, if it's illogical for some commands to reconnect by design then we might call some commands reconnectable |
They can't live forever unless you are doing something wrong or unexpected in your application so you might prefer to check where the problem lies in such cases. Or you might indeed need a whole lot of potentially-idling connections for pub/sub or BRPOP/BLOP scenarios, in which case you might need to rely on master/slave replication and use different slaves for subscribers.
You can do a
This would not work with command pipelining and lead to unpredictable behaviors with MULTI / EXEC contexts (once you get a disconnection, the whole transaction is obviously discarded by the server). Hashing a command, on the other hand, is something that does not depend on the state of a client / context / underlying connection. |
first I would live you quick response and following the issue second, I agree that multi/exec should not reconnect but I really feel that other commands should reconnect (eg. get/set or blpop) in a sane way we are using Yii's CRedisCache and it uses a getter that caches the connection
you might say this is their problem, and you might say it's the problem of our search team to add disconnect/connect/ping ..etc. but I like to think about separation of concern principle, our search team should never go deep and know how the redis component work, it should just get and set keys I guess this is part of making Predis bullet-proof. |
Sorry, but I won't add auto-reconnect features to Predis :-) This is probably one of the few things that have been set in stone since long ago and I still think that your proposal would lead to an hackish implementation with unpredictable behaviors. Specific needs such as yours are up to end-developers to implement, that's the very reason why Predis has been designed to be extremely modular. In your scenario you can extend the underlying connection class Could this approach work for you? PS: I'd close this issue and #75, we can move to private email if you need some tips. |
it seems that the author of redis agrees with you https://twitter.com/antirez/status/207117083790684161
https://twitter.com/antirez/status/207122021665091584
but before I use 0 timeouts I have a concern from my previous experience with php mysql module once upon time, our mysql server black listed one of our web server (with max user connections exceeded) because there was a php fatal error prevent php script to reach the line where the script closes the connection, and with many people visiting the web server many connections opened but none closes his connection properly
of course the OS will close the connection when the process end but in many cases the process where php lives is a long-living daemon (eg. could be a preforked apache process, php fast cgi daemon, php-fpm daemon, ..etc) in other words OS won't close those connections because the process did not terminate (only the script terminated) according to Salvatore Sanfilippo (author of redis)
which type of those two do does Predis uses |
When using That said, Predis can support persistent connections when |
thank you for such deep follow up, |
I would like to thank you for helping me regarding the mysql error too by tuning php.ini http://dev.mysql.com/doc/refman/5.0/en/blocked-host.html
|
hi,
we used to have an issue with legacy version of Predis, we have upgraded to the latest Predis stable 7.2
and we still face the same issue but it's less frequent
the problem goes like this:
we have a loop on blpop which crashes with the following trace
The text was updated successfully, but these errors were encountered: