Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for handling of {ldr,...} messages of different arity. #1

Merged
merged 1 commit into from

2 participants

@argv0

In Riak EnterpriseDS we had some problems with deadlock on selective receive of the {ldr,...} messages.

If you look at the source, there are {ldr,...} messages with arities of both 4 and 5. In production with EnterpriseDS, we saw a deadlock occur while trying to match a 4-arity {ldr,...} message with a 5-arity receive (in safe_loop). The following is pasted from a console session while the leader was hung:

7> process_info(whereis(leader_regname)).
[{current_function,{gen_leader,safe_loop,4}},...]

8> rp(lists:sublist(element(2, erlang:process_info(whereis(leader_regname), messages)), 5)).
[{ldr,syncmsg,{2,26,1},},...]

This pull request changes all {ldr,...} messages to 5-tuples and adjusts the arities in the receive clauses accordingly.

Original fix by Jon Meredith jmeredith@basho.com

@argv0

previously, if we received a 5-tuple here the leader would hang.

@argv0

make sure we always send {ldr,...} messages as 5-tuples.

@argv0

Dave, y u no merge?

@KirinDave
Owner

Github never told me about this! I literally have 0 messages in my github inbox about this! I am so sorry!

@KirinDave KirinDave merged commit dca52b9 into KirinDave:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 combined_version/gen_leader.erl
View
4 combined_version/gen_leader.erl
@@ -697,7 +697,7 @@ loop(#server{parent = Parent,
loop(Server,Role,E,Msg);
{ack,_,_} ->
loop(Server,Role,E,Msg);
- {ldr,_,_,_} ->
+ {ldr,_,_,_,_} ->
loop(Server,Role,E,Msg);
{normQ,_,_} ->
loop(Server,Role,E,Msg);
@@ -1226,7 +1226,7 @@ hasBecomeLeader(E,Server,Msg) ->
lists:foreach(
fun(Node) ->
{E#election.name,Node} !
- {ldr, Synch, E#election.elid, self()}
+ {ldr, Synch, E#election.elid, E#election.worker_nodes, self()}
end,E#election.acks),
%% Make sure we will try to contact all workers!
Something went wrong with that request. Please try again.