Skip to content

Commit

Permalink
Never use infinity request timeouts
Browse files Browse the repository at this point in the history
As described in #156, there are several types of timeouts in the client.
The timeout that is generally provided as the last argument to client
operations is used to create timers which prevent us from waiting for
every on messages for TCP data (from gen_tcp). There are several cases
where this timeout was hardcoded to infinity. This can cause the client
to hang on these requests for a (mostly) unbounded time. Even when using
a gen_server timeout, the gen_server itself will continue to wait for
the message to come, with no timeout. Further, because of #155, we
simply use the `ServerTimeout` as the `RequestTimeout`, if there is not
a separate `RequestTimeout`. It's possible that the `RequestTimeout` can
fire before the `ServerTimeout` (this timeout is remote), but we'd
otherwise just be picking some random number to be the difference
between them. Addressing #155 will shed more light on this.
  • Loading branch information
reiddraper committed Feb 18, 2014
1 parent cf248b1 commit 5aa1ab0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/riakc_pb_socket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ stream_list_buckets(Pid, Type, Options) ->
gen_server:call(Pid, {req, #rpblistbucketsreq{timeout=ServerTimeout,
type=Type,
stream=true},
infinity, {ReqId, self()}}, infinity).
ServerTimeout, {ReqId, self()}}, infinity).

legacy_list_buckets(Pid, Options) ->
ServerTimeout =
Expand All @@ -457,7 +457,7 @@ legacy_list_buckets(Pid, Options) ->
ST -> ST
end,
gen_server:call(Pid, {req, #rpblistbucketsreq{timeout=ServerTimeout},
infinity}, infinity).
ServerTimeout}, infinity).


%% @doc List all keys in a bucket
Expand Down Expand Up @@ -518,7 +518,7 @@ stream_list_keys(Pid, Bucket, Options) ->
{T, B} = maybe_bucket_type(Bucket),
ReqMsg = #rpblistkeysreq{type = T, bucket = B, timeout = ServerTimeout},
ReqId = mk_reqid(),
gen_server:call(Pid, {req, ReqMsg, infinity, {ReqId, self()}},
gen_server:call(Pid, {req, ReqMsg, ServerTimeout, {ReqId, self()}},
infinity).

%% @doc Get bucket properties.
Expand Down Expand Up @@ -1006,9 +1006,9 @@ get_index_eq(Pid, Bucket, Index, Key, Opts) ->
Call = case Stream of
true ->
ReqId = mk_reqid(),
{req, Req, infinity, {ReqId, self()}};
{req, Req, Timeout, {ReqId, self()}};
false ->
{req, Req, infinity}
{req, Req, Timeout}
end,
gen_server:call(Pid, Call, CallTimeout).

Expand Down Expand Up @@ -1061,9 +1061,9 @@ get_index_range(Pid, Bucket, Index, StartKey, EndKey, Opts) ->
Call = case Stream of
true ->
ReqId = mk_reqid(),
{req, Req, infinity, {ReqId, self()}};
{req, Req, Timeout, {ReqId, self()}};
false ->
{req, Req, infinity}
{req, Req, Timeout}
end,
gen_server:call(Pid, Call, CallTimeout).

Expand Down Expand Up @@ -1098,7 +1098,7 @@ cs_bucket_fold(Pid, Bucket, Opts) when is_pid(Pid), (is_binary(Bucket) orelse
continuation=Continuation,
timeout=Timeout},
ReqId = mk_reqid(),
Call = {req, Req, infinity, {ReqId, self()}},
Call = {req, Req, Timeout, {ReqId, self()}},
gen_server:call(Pid, Call, CallTimeout).

%% @doc Return the default timeout for an operation if none is provided.
Expand Down

0 comments on commit 5aa1ab0

Please sign in to comment.