Skip to content

Commit

Permalink
Retry when pool is full
Browse files Browse the repository at this point in the history
Fixes adrienmo#28 and obsoletes PR adrienmo#29.

Retry is implemented for query, but not for query_noreply. Perhaps it should.
  • Loading branch information
zuiderkwast committed Sep 17, 2020
1 parent 02973e7 commit 868b6fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/eredis_cluster.erl
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ query_noreply(Command, PoolKey) ->
Transaction = fun(Worker) -> qw_noreply(Worker, Command) end,
{Pool, _Version} = eredis_cluster_monitor:get_pool_by_slot(Slot),
eredis_cluster_pool:transaction(Pool, Transaction),
%% TODO: Retry if pool is full?
ok.

query(_, _, ?REDIS_CLUSTER_REQUEST_TTL) ->
Expand Down Expand Up @@ -407,6 +408,10 @@ handle_transaction_result(Result, Version) ->
{error, tcp_closed} ->
retry;

%% Pool is full
{error, full} ->
retry;

%% Other TCP issues
%% See reasons: https://erlang.org/doc/man/inet.html#type-posix
{error, Reason} when is_atom(Reason) ->
Expand Down
2 changes: 2 additions & 0 deletions src/eredis_cluster_pool_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ init(Args) ->

{ok, #state{conn=Conn}}.

query(full, _Commands) ->
{error, full};
query(Worker, Commands) ->
gen_server:call(Worker, {'query', Commands}).

Expand Down

0 comments on commit 868b6fb

Please sign in to comment.