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

FIX #28 #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/eredis_cluster.erl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ handle_transaction_result(Result, Version) ->
% If we detect a node went down, we should probably refresh the slot
% mapping.
{error, no_connection} ->
logger:error("eredis_cluster:handle_transaction_result <--> {error, no_connection}",[]),
eredis_cluster_monitor:refresh_mapping(Version),
retry;

Expand All @@ -202,11 +203,17 @@ handle_transaction_result(Result, Version) ->
% the next request. We don't need to refresh the slot mapping in this
% case
{error, tcp_closed} ->
logger:error("eredis_cluster:handle_transaction_result <--> {error, no_connection}",[]),
retry;

{error, retry} ->
logger:error("eredis_cluster:handle_transaction_result <--> {error, retry}",[]),
retry;

% Redis explicitly say our slot mapping is incorrect, we need to refresh
% it
{error, <<"MOVED ", _/binary>>} ->
logger:error("eredis_cluster:handle_transaction_result <--> {error, MOVED} Result = ~",[Result]),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an issue here? ~p

eredis_cluster_monitor:refresh_mapping(Version),
retry;

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 @@ -38,6 +38,8 @@ init(Args) ->

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

query(full, _Commands) ->
{error, retry};
Comment on lines +41 to +42
Copy link

@zuiderkwast zuiderkwast Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, eredis_cluster is using poolboy:transaction/2 which is using poolboy:checkout/3 with Block = true. Checkout can only return full when Block =:= false. Therefore, if the pool is full, the transaction fun never gets called so this PR just adds dead code.

Instead, when the pool doesn't have workers available, we get an exit:{timeout, {gen_server, call, _}} exception from poolboy:transaction/2. This is turned into {error, no_connection} by the try-catch in eredis_cluster_pool and then it triggers a refesh mappings and then a retry in eredis_cluster.

Refresh mappings isn't necessary in this case. A retry without refresh mappings would suffice. We have done it in the Nordix fork.

query(Worker, Commands) ->
gen_server:call(Worker, {'query', Commands}).

Expand Down