-
-
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
Error while reading line from the server #32
Comments
Your issue is quite strange. That kind of exception is usually thrown when the socket (which is already connected) reaches a timeout during read or write operations, but the fact that you are seeing these kind of errors even when dealing with a local instance of Redis makes it indeed weird. Did you use a custom (and low) value for the |
No, we didn't. The only configuration parameter passed to the client is This may not be interesting, but I hacked the client a bit to try to read again at the moment the exception occurs, and append the read string to the exception text. I didn't take too many samples, but the read string looked to be a few characters of valid output (didn't actually verify). Anyway, it wasn't empty. Edit. Another data point: there's usually a whole bunch of error instances within about one second, but nothing before or after it. I realize this could point towards a problem in Redis; is there a way to rule out Predis as the culprit (other than rewriting the calls to use another language/client)? |
Can you try to wrap the calls that usually end up generating the exception in a <?php
try {
// Redis commands
}
catch (Predis\CommunicationException $exception) {
$stream = $exception->getConnection()->getSocket();
$metadata = var_export(stream_get_meta_data($stream), true);
// log the $metadata string somewhere so that you can retrieve it
throw $exception;
} With By the way the value of |
Very well, we'll try both. Work starts about 12 hours from now (we're on CET), I'll report back with the results. Thank you. |
Sorry, I just noticed that the current behaviour of Predis doesn't play nice with that snippet of code. You should temporarily modify this line of code to return |
OK, done. There was no exception yet. |
Got a few errors, here's an example (they all look the same):
The |
Raising the value of How many concurrent client are connected to your Redis instances on average? Would it be possible for you to use UNIX domain sockets instead of TCP/IP to connect to the Redis instances that run on the locahost and see if you still get those random errors out of them? |
On two Redis servers with the issue there are 17 +/- 5 connections. One had a maximal spike of 30, the other has a daily spike of 60-100 (both last for a few minutes, and they don't match the times of the errors). I'll try using UNIX sockets for one of the servers. We got a very small number of errors similar to the following:
This could be just because of this change, but maybe it has some extra info for you. |
Well, seeing that you get timeouts also during connect() operations is somewhat reassuring, it would have been totally weird otherwise :-) Anyway, 100 simultaneous connections to Redis shouldn't pose any problem (at least on Redis-side). By the way I just noticed that you are running PHP with Xdebug loaded. Aside from the fact that Xdebug can slow your PHP code down quite a bit for a production environment, I don't know if it could mess with PHP streams or something under load. You should try to disable it, if possible, and if even doing this doesn't solve the problem... well, I'm at loss for words. From how things are turning out this doesn't seem a bug of Predis, and the only things left I can think of are:
|
Very well, if disabling Xdebug doesn't solve the problem, then I'll try to reproduce this with another client library. Hopefully that will narrow things down enough for the Redis folks to figure this out. We'll use unix sockets for loopback connections, even if they don't solve this (speedup is good for the health), so thanks for that pointer as well. Thank you for your time :) |
Let me know how things go, now I'm curious :-) |
Sure, I'll write here with the results. There weren't any errors since I disabled Xdebug, I hope it'll stay that way. |
Just adding a link to an ongoing discussion on this matter (timeouts) from the Redis mailing list since it has some interesting tips. |
Actually, I wrote the OP of that thread :) It was still very nice of you to post the link. |
The cause of the issue was a faulty Realtek driver (r8169 before kernel 2.6.30 is buggy, have to use r8168). Nothing to do with Redis or Predis. |
Thanks for the update, this might be a valuable information for others. Debugging these kind of weird issues can be hard and time consuming when the cause is somewhere at a lower level. |
Abesto, sorry to bother - but we are experiencing the same issue i was wondering how did u go about find out that "The cause of the issue was a faulty Realtek driver" ?? Thanks! |
@rookie7799 No problem at all. Mention of the problem and a detailed solution at Hetzner: http://wiki.hetzner.de/index.php/Installation_des_r8168-Treibers/en Sorry for taking so long to answer. |
I got the same issue when I use command "brpop bar 0" in code. setting read_write_timeout to -1 can solve it but...are there any better solutions? or can this solution cause other unknown issues?by the way,for our system, 60s timeout is not enough:( |
You could do blocking operations with a non-zero second argument. This releases the block once that "timeout" is reached. You can then run some checks, and issue the blocking command again. This way you also avoid having to configure the server for not dropping very long connections. |
It's a good idea, thanks for your answer:) |
Sorry for bringing this up again after so much time, but I think I have a different reason why I get this error message. I tried debugging the stream as mentioned earlier and got this:
Any idea about blocking mode connection? I saw other PHP Redis library has this configurable. We just switched from phpredis and this is a cron job, the error happens exactly after 60 seconds. Thank you! |
This is how I managed to capture the debug info:
I get the following:
I have set read_write_timeout to -1, timeout in redis.conf to 0, second param to blpop as 0. Has anyone managed to find out more about this? More info: |
No Ben, I haven't been able to resolve this.
Ben Cromwell wrote:
…
Hi @pravindahal <https://github.com/pravindahal>
Thanks for posting the debug capturing code. Did you get anywhere
towards a resolution?
I have a similar issue:-
|array (
'stream_type' => 'tcp_socket/ssl',
'mode' => 'r+',
'unread_bytes' => 0,
'seekable' => false,
'timed_out' => false,
'blocked' => true,
'eof' => false,
)
|
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32 (comment)>, or
mute the thread
<https://github.com/notifications/unsubscribe-auth/AA2nC7YRPNChZdEOx9c1N3pBJNbr0KW3ks5rDT5XgaJpZM4HN5ze>.
|
Apologies, I deleted my comment as I wasn't sure the issue was the same
after more debugging.
It might be though.
I swapped out Predis for phpredis and experienced the same error. After
more searching I found the setting `default_socket_timeout` and set it to
-1. This is in php.ini
http://php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout
That did the trick. It seems that is necessary despite setting the
connection parameter read_write_timeout. PHP's setting trumps it, both are
required by the looks of things.
…On 30 November 2016 at 11:43, Pravin Dahal ***@***.***> wrote:
No Ben, I haven't been able to resolve this.
Ben Cromwell wrote:
>
> Hi @pravindahal <https://github.com/pravindahal>
>
> Thanks for posting the debug capturing code. Did you get anywhere
> towards a resolution?
>
> I have a similar issue:-
>
> |array (
> 'stream_type' => 'tcp_socket/ssl',
> 'mode' => 'r+',
> 'unread_bytes' => 0,
> 'seekable' => false,
> 'timed_out' => false,
> 'blocked' => true,
> 'eof' => false,
> )
> |
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#32 (comment)>, or
> mute the thread
> <https://github.com/notifications/unsubscribe-auth/
AA2nC7YRPNChZdEOx9c1N3pBJNbr0KW3ks5rDT5XgaJpZM4HN5ze>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#32 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApvTxieAw1-Jfa6NvXJbwKTW8VP9rgfks5rDWFYgaJpZM4HN5ze>
.
|
I find myself back here almost a year later and feel compelled to comment. Composer doesn't work (install/update packages) with that socket setting changed. No idea why the package doesn't seem to respect the configuration settings and is unable to override PHP's default. Leaving this comment here in case anyone is reading this and knows the solution! |
In my case configuring Redis was not enough setting |
CommunicationException
s are thrown with the message 'Error while reading line from the server' from time to time. The Predis part of an example stack trace:We couldn't find anything in common in the affected scripts. Some errors are from a local Redis server, some from a remote one. An example that sometimes generates this error:
The script is run by Apache, browsers call it directly by URL, so there can be a lot of instances running at once. The following Redis commands are run via Predis (in this order;
a
,b
,c
andd
are different tables):The bold commands are those that have ever generated the error. The majority (99%) is on AUTH.
Environment:
The text was updated successfully, but these errors were encountered: