Skip to content
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

Query timeout shorter than specified #51

Closed
martinrehfeld opened this issue Apr 1, 2014 · 5 comments
Closed

Query timeout shorter than specified #51

martinrehfeld opened this issue Apr 1, 2014 · 5 comments

Comments

@martinrehfeld
Copy link

Using a timeout of 60s like this

eredis:q(pid(0,17393,766), ["SMEMBERS", "access_64628"], 60000).

I still get a timeout after 5s. It looks to me as if another gen_server:call is triggered internally with the default timeout.

** exception exit: {{timeout,{gen_server,call,
                                         [<0.17393.766>,
                                          {request,[[<<"*">>,"3",<<"\r\n">>],
                                                    [[<<"$">>,"4",<<"\r\n">>,<<"SADD">>,<<"\r\n">>],
                                                     [<<"$">>,"12",<<"\r\n">>,<<"access_64645">>,<<"\r\n">>],
                                                     [<<"$">>,"57",<<"\r\n">>,
                                                      <<"some data "...>>,
                                                      <<"\r\n">>]]]},
                                          5000]}},
                    {gen_server,call,
                                [<0.17393.766>,
                                 {request,[[<<"*">>,"2",<<"\r\n">>],
                                           [[<<"$">>,"8",<<"\r\n">>,<<"SMEMBERS">>,<<"\r\n">>],
                                            [<<"$">>,"12",<<"\r\n">>,<<"access_64628">>,<<"\r\n">>]]]},
                                 60000]}}

Any pointers where to start looking for a fix?

Cheers,
Martin

@knutin
Copy link
Collaborator

knutin commented Apr 1, 2014

Hmm, this is very weird. Maybe it's the "SADD" that times out? Are you also using a 60 second timeout there?

@martinrehfeld
Copy link
Author

Good catch. So the problem seems to be of different nature than I originally thought. The SADD is issued form a different process to the same redis_client. But I still get above exception on the SMEMBERS call issued from the shell via eredis:q/3. Should they be independent? Or is it bad practice to talk to the same redis_client process from different processes?

@knutin
Copy link
Collaborator

knutin commented Apr 1, 2014

Hmm, okay. Is the process sending the SADD requests spawned from the shell? Is it possible for you to show me some code that I could use to reproduce?

In general, one eredis_client process can handle any number of clients. On a fast machine, one eredis_client process will happily do 100k+ requests to a single Redis instance. eredis_client internally is asynchronous. If Redis takes a long time to respond to a specific command (any of the blocking commands, for example), you need to use separate eredis_client processes.

@martinrehfeld
Copy link
Author

The setup is like this. One process (not spawned from the shell, but a supervised gen_server already running in the system) is doing SADD like this eredis:q(Pid, ["SADD", SetName, Key]). And then I issued the eredis:q(pid(0,17393,766), ["SMEMBERS", "access_64628"], 60000). from an attached shell (Pid above is pid(0,17393,766)) and got the exception exit.... The "access_64628" set has about 1.2M members and it takes about 20 seconds to complete the SMEMBERS call.

With my current understanding it looks like the timeouts of the two eredis:q calls are not independent as the SMEMBERS call fails after around 5s. This also seems to kill the eredis_client process.

Using a different eredis_client for the SMEMBERS call works fine.

@knutin
Copy link
Collaborator

knutin commented Apr 1, 2014

Okay, this makes sense to me now. :-)

Commands to Redis are executed in the order they arrive to the eredis_client process. Redis will process one command at a time and respond in the same order as the commands were sent.

If a SMEMBERS call arrives before SADD, the `SADD' would have to wait more than 20 seconds for a response which would make it time out. However, I can't explain why you see that exception in your shell call.

In this case, where some commands execute instantly, while others are extremely slow, using two clients like you are currently doing makes sense.

@knutin knutin closed this as completed May 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants