Skip to content

Registry fix #339

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

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion src/ra.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application,ra,
[{description,"Raft library"},
{vsn,"2.4.3"},
{vsn,"2.4.4"},
{licenses,["Apache-2.0","MPL-2.0"]},
{links,[{"github","https://github.com/rabbitmq/ra"}]},
{modules,[]},
Expand Down
10 changes: 7 additions & 3 deletions src/ra_directory.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,21 @@ register_name(System, UId, Pid, ParentPid, ServerName, ClusterName)
when is_atom(System) ->
register_name(get_names(System), UId, Pid,
ParentPid, ServerName, ClusterName);
register_name(#{
directory := Directory,
register_name(#{directory := Directory,
directory_rev := DirRev} = System, UId, Pid, ParentPid,
ServerName, ClusterName) ->
true = ets:insert(Directory, {UId, Pid, ParentPid, ServerName,
ClusterName}),
case uid_of(System, ServerName) of
undefined ->
ok = dets:insert(DirRev, {ServerName, UId});
_ ->
UId ->
%% no need to insert into dets table if already there
ok;
OtherUId ->
ok = dets:insert(DirRev, {ServerName, UId}),
?WARN("ra server with name ~s UId ~s replaces prior UId ~s",
[ServerName, UId, OtherUId]),
ok
end.

Expand Down
20 changes: 14 additions & 6 deletions src/ra_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1346,8 +1346,14 @@ overview(#{cfg := #cfg{effective_machine_module = MacMod} = Cfg,
machine_state := MacState,
aux_state := Aux
} = State) ->
O0 = maps:with([current_term, commit_index, last_applied,
cluster, leader_id, voted_for], State),
O0 = maps:with([current_term,
commit_index,
last_applied,
cluster,
leader_id,
voted_for,
cluster_change_permitted,
cluster_index_term ], State),
O = maps:merge(O0, cfg_to_map(Cfg)),
LogOverview = ra_log:overview(Log),
MacOverview = ra_machine:overview(MacMod, MacState),
Expand Down Expand Up @@ -2069,7 +2075,9 @@ update_term_and_voted_for(Term, VotedFor, #{cfg := #cfg{uid = UId} = Cfg,

update_term(Term, State = #{current_term := CurTerm})
when Term =/= undefined andalso Term > CurTerm ->
update_term_and_voted_for(Term, undefined, State);
update_term_and_voted_for(Term, undefined,
State#{query_index => 0,
queries_waiting_heartbeats => queue:new()});
update_term(_, State) ->
State.

Expand Down Expand Up @@ -2595,9 +2603,9 @@ update_query_index(State, NewQueryIndex) ->
State#{query_index => NewQueryIndex}.

reset_query_index(#{cluster := Cluster} = State) ->
State#{cluster =>
maps:map(fun(_PeerId, Peer) -> Peer#{query_index => 0} end,
Cluster)}.
State#{cluster => maps:map(fun(_PeerId, Peer) ->
Peer#{query_index => 0}
end, Cluster)}.


heartbeat_rpc_effects(Peers, Id, Term, QueryIndex) ->
Expand Down