fix: upgrade ekka to 0.18.3 to ensure the leader correct

This commit is contained in:
JianBo He 2024-01-25 14:47:59 +08:00
parent ff0fd65f9d
commit 52a7b45d97
5 changed files with 46 additions and 6 deletions

View File

@ -28,7 +28,7 @@
{gproc, {git, "https://github.com/emqx/gproc", {tag, "0.9.0.1"}}},
{cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.2"}}},
{esockd, {git, "https://github.com/emqx/esockd", {tag, "5.11.1"}}},
{ekka, {git, "https://github.com/emqx/ekka", {tag, "0.18.1"}}},
{ekka, {git, "https://github.com/emqx/ekka", {tag, "0.18.3"}}},
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "3.3.1"}}},
{hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.40.4"}}},
{emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.5.3"}}},

View File

@ -69,7 +69,8 @@ handle_call({invite_async, Node, JoinTo}, _From, State) ->
undefined ->
Caller = self(),
Task = spawn_link_invite_worker(Node, JoinTo, Caller),
{reply, ok, State#{Node => Task}};
State1 = remove_finished_task(Node, State),
{reply, ok, State1#{Node => Task}};
WorkerPid ->
{reply, {error, {already_started, WorkerPid}}, State}
end;
@ -157,6 +158,11 @@ find_node_name_via_worker_pid(WorkerPid, {Key, Task, I}) ->
find_node_name_via_worker_pid(WorkerPid, maps:next(I))
end.
remove_finished_task(Node, State = #{history := History}) ->
State#{history => maps:remove(Node, History)};
remove_finished_task(_Node, State) ->
State.
state_to_invitation_status(State) ->
History = maps:get(history, State, #{}),
{Succ, Failed} = lists:foldl(

View File

@ -190,7 +190,7 @@ t_cluster_invite_async(Config) ->
lists:sort(Core1Resp)
),
%% force leave the core2 and replicant
%% force leave the core2
{204} = rpc:call(
Core1,
emqx_mgmt_api_cluster,
@ -260,7 +260,41 @@ t_cluster_invite_async(Config) ->
}
],
lists:sort(Core1Resp3)
).
),
%% force leave the core2
{204} = rpc:call(
Core1,
emqx_mgmt_api_cluster,
force_leave,
[delete, #{bindings => #{node => atom_to_binary(Core2)}}]
),
%% invite core2 again
?assertMatch(
{200},
Invite(Core2)
),
%% assert: core2 is in_progress status
{200, InvitationStatus1} = rpc:call(Core1, emqx_mgmt_api_cluster, get_invitation_status, [
get, #{}
]),
?assertMatch(
#{succeed := [], in_progress := [#{node := Core2}], failed := []},
InvitationStatus1
),
%% waiting the async invitation_succeed
?assertMatch({succeed, _}, waiting_the_async_invitation_succeed(Core1, Core2)),
{200, InvitationStatus2} = rpc:call(Core1, emqx_mgmt_api_cluster, get_invitation_status, [
get, #{}
]),
?assertMatch(
#{succeed := [#{node := Core2}], in_progress := [], failed := []},
InvitationStatus2
),
ok.
cluster(Config) ->
NodeSpec = #{apps => ?APPS},

View File

@ -55,7 +55,7 @@ defmodule EMQXUmbrella.MixProject do
{:cowboy, github: "emqx/cowboy", tag: "2.9.2", override: true},
{:esockd, github: "emqx/esockd", tag: "5.11.1", override: true},
{:rocksdb, github: "emqx/erlang-rocksdb", tag: "1.8.0-emqx-2", override: true},
{:ekka, github: "emqx/ekka", tag: "0.18.1", override: true},
{:ekka, github: "emqx/ekka", tag: "0.18.3", override: true},
{:gen_rpc, github: "emqx/gen_rpc", tag: "3.3.1", override: true},
{:grpc, github: "emqx/grpc-erl", tag: "0.6.12", override: true},
{:minirest, github: "emqx/minirest", tag: "1.3.15", override: true},

View File

@ -83,7 +83,7 @@
{cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.2"}}},
{esockd, {git, "https://github.com/emqx/esockd", {tag, "5.11.1"}}},
{rocksdb, {git, "https://github.com/emqx/erlang-rocksdb", {tag, "1.8.0-emqx-2"}}},
{ekka, {git, "https://github.com/emqx/ekka", {tag, "0.18.1"}}},
{ekka, {git, "https://github.com/emqx/ekka", {tag, "0.18.3"}}},
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "3.3.1"}}},
{grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.12"}}},
{minirest, {git, "https://github.com/emqx/minirest", {tag, "1.3.15"}}},