chore: improve wait_for_nodes_commit/4 function
This commit is contained in:
parent
758b1979ab
commit
33341011d8
|
@ -511,7 +511,7 @@ do_alarm(Fun, Res, #{tnx_id := Id} = Meta) ->
|
||||||
emqx_alarm:Fun(cluster_rpc_apply_failed, Meta#{result => ?TO_BIN(Res)}, AlarmMsg).
|
emqx_alarm:Fun(cluster_rpc_apply_failed, Meta#{result => ?TO_BIN(Res)}, AlarmMsg).
|
||||||
|
|
||||||
wait_for_all_nodes_commit(TnxId, Delay, Remain) ->
|
wait_for_all_nodes_commit(TnxId, Delay, Remain) ->
|
||||||
Lagging = lagging_node(TnxId),
|
Lagging = lagging_nodes(TnxId),
|
||||||
Stopped = stopped_nodes(),
|
Stopped = stopped_nodes(),
|
||||||
case Lagging -- Stopped of
|
case Lagging -- Stopped of
|
||||||
[] when Stopped =:= [] ->
|
[] when Stopped =:= [] ->
|
||||||
|
@ -533,17 +533,18 @@ wait_for_nodes_commit(RequiredSyncs, TnxId, Delay, Remain) ->
|
||||||
false when Remain > 0 ->
|
false when Remain > 0 ->
|
||||||
wait_for_nodes_commit(RequiredSyncs, TnxId, Delay, Remain - Delay);
|
wait_for_nodes_commit(RequiredSyncs, TnxId, Delay, Remain - Delay);
|
||||||
false ->
|
false ->
|
||||||
Lagging = lagging_node(TnxId),
|
case lagging_nodes(TnxId) of
|
||||||
Stopped = stopped_nodes(),
|
[] ->
|
||||||
case Lagging -- Stopped of
|
ok;
|
||||||
%% All commit but The succeedNum > length(nodes()).
|
Lagging ->
|
||||||
[] when Stopped =:= [] -> ok;
|
case stopped_nodes() of
|
||||||
[] -> {stopped_nodes, Stopped};
|
[] -> {peers_lagging, Lagging};
|
||||||
[_ | _] -> {peers_lagging, Lagging}
|
Stopped -> {stopped_nodes, Stopped}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
lagging_node(TnxId) ->
|
lagging_nodes(TnxId) ->
|
||||||
{atomic, Nodes} = transaction(fun ?MODULE:commit_status_trans/2, ['<', TnxId]),
|
{atomic, Nodes} = transaction(fun ?MODULE:commit_status_trans/2, ['<', TnxId]),
|
||||||
Nodes.
|
Nodes.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue