Skip to content

Commit

Permalink
Check already_joined in verify_tried_joining
Browse files Browse the repository at this point in the history
Second way of checking join status for each table:
just ask get_server directly

Useful, if remote node sends us cancel_check
  • Loading branch information
arcusfelis committed Jan 31, 2024
1 parent 9724c76 commit c03a014
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/cets_discovery.erl
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,9 @@ verify_tried_joining(State = #{nodes := Nodes, tables := Tables}) ->
NodesToJoin = [Node || Node <- Nodes, lists:member(Node, AvailableNodes)],
Missing = [
{Node, Table}
|| Node <- NodesToJoin, Table <- Tables, not has_join_result_for(Node, Table, State)
|| Node <- NodesToJoin,
Table <- Tables,
not (has_join_result_for(Node, Table, State) orelse already_joined(Node, Table))
],
case Missing of
[] -> [];
Expand All @@ -606,6 +608,18 @@ verify_tried_joining(State = #{nodes := Nodes, tables := Tables}) ->
has_join_result_for(Node, Table, #{results := Results}) ->
[] =/= [R || R = #{node := N, table := T} <- Results, N =:= Node, T =:= Table].

-spec already_joined(node(), cets:table_name()) -> boolean().
already_joined(Node, Table) ->
lists:member(
Node,
try
%% Careful, it is a blocking call
cets:other_nodes(Table)
catch
_:_ -> []
end
).

-spec handle_system_info(state()) -> system_info().
handle_system_info(State) ->
State#{
Expand Down

0 comments on commit c03a014

Please sign in to comment.