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
EMQX-9152 optimize mria running nodes #135
EMQX-9152 optimize mria running nodes #135
Conversation
ede2e6d
to
f958508
Compare
@@ -187,7 +233,7 @@ ping(Node, Member) -> | |||
ping(Node, _Member, 0) -> | |||
?LOG(error, "Failed to ping ~s~n", [Node]); | |||
ping(Node, Member, Retries) -> | |||
case mria_node:is_running(Node) of | |||
case mria_node:is_running(Node, ?MODULE, is_running) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, this should give slightly stronger guarantee, that Node
is ready to receive a ping.
Previously it was calling mria_sup:is_running/0
which checks if mria_sup
is a registered process.
However, supervisor process is registered at the early stage: before its init
returns and all the children are started (https://github.com/emqx/otp/blob/emqx-OTP-25.1.2/lib/stdlib/src/gen.erl#L192).
Thus, it was possible to send a cast message to mria_membership
server on another node when mria_sup
was already running but mria_membership
was not yet.
f958508
to
a9df38e
Compare
8b8b379
to
92405a3
Compare
test/mria_membership_SUITE.erl
Outdated
, ?snk_meta := #{node := ObserveNode}} | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (coding style):
, ?snk_meta := #{node := ObserveNode}} | |
), | |
, ?snk_meta := #{node := ObserveNode} | |
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
src/mria_node.erl
Outdated
|
||
%% @doc Is the application running? | ||
%% M:F/0 must return boolean() | ||
-spec is_running(node(), atom(), atom()) -> boolean(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be done via mria_config:callback()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I think it will rather differ from existing callbacks both semantically and name-vise:
-type callback() :: start
| stop
| {start | stop, mria_rlog:shard()}
| core_node_discovery.
Adding something like is_mria_membership_running
will not explain on which event this callback is expected to be called.
Also, all callbacks are now only used outside Mria (no callback is registered within Mria), but this one would seem to be private (I think we don't want to allow changing the way Mria is going to check if mria_membership
is already running on anther node).
My intention of adding it to mria_node
module was to (hopefully) raise some awareness that mria_node:is_running/0
may be not perfect in all the cases, so a developer is encouraged to implement a specific boolean function and use it with mria_node:is_running/3
...
92405a3
to
02fe9e8
Compare
src/mria_node.erl
Outdated
|
||
%% @doc Is the application running? | ||
%% M:F/0 must return boolean() | ||
-spec is_running(node(), atom(), atom()) -> boolean(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-spec is_running(node(), atom(), atom()) -> boolean(). | |
-spec is_running(node(), module(), atom()) -> boolean(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
#{ ?snk_kind := Kind | ||
, node := ActionNode | ||
, ?snk_meta := #{node := ObserveNode} | ||
}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}). | |
}). | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Old mria_membership API is kept compatible: no function shows info about replicant nodes.
…formation Closes: EMQX-9152
02fe9e8
to
1273fd2
Compare
No description provided.