Skip to content

Commit 868b6fb

Browse files
committed
Retry when pool is full
Fixes adrienmo#28 and obsoletes PR adrienmo#29. Retry is implemented for query, but not for query_noreply. Perhaps it should.
1 parent 02973e7 commit 868b6fb

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/eredis_cluster.erl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ query_noreply(Command, PoolKey) ->
372372
Transaction = fun(Worker) -> qw_noreply(Worker, Command) end,
373373
{Pool, _Version} = eredis_cluster_monitor:get_pool_by_slot(Slot),
374374
eredis_cluster_pool:transaction(Pool, Transaction),
375+
%% TODO: Retry if pool is full?
375376
ok.
376377

377378
query(_, _, ?REDIS_CLUSTER_REQUEST_TTL) ->
@@ -407,6 +408,10 @@ handle_transaction_result(Result, Version) ->
407408
{error, tcp_closed} ->
408409
retry;
409410

411+
%% Pool is full
412+
{error, full} ->
413+
retry;
414+
410415
%% Other TCP issues
411416
%% See reasons: https://erlang.org/doc/man/inet.html#type-posix
412417
{error, Reason} when is_atom(Reason) ->

src/eredis_cluster_pool_worker.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ init(Args) ->
3636

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

39+
query(full, _Commands) ->
40+
{error, full};
3941
query(Worker, Commands) ->
4042
gen_server:call(Worker, {'query', Commands}).
4143

0 commit comments

Comments
 (0)