Skip to content

Commit ab7c609

Browse files
committed
Clear init finished and code refactor
1 parent 2a7557e commit ab7c609

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

deps/rabbit/src/rabbit.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ stop() ->
467467
Product = product_name(),
468468
?LOG_INFO("~ts is asked to stop...", [Product],
469469
#{domain => ?RMQLOG_DOMAIN_PRELAUNCH}),
470+
rabbit_db:clear_init_finished(),
470471
do_stop(),
471472
?LOG_INFO(
472473
"Successfully stopped ~ts and its dependencies",

deps/rabbit/src/rabbit_db.erl

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
is_virgin_node/0, is_virgin_node/1,
2424
dir/0,
2525
ensure_dir_exists/0,
26-
is_init_finished/0]).
26+
is_init_finished/0,
27+
clear_init_finished/0]).
2728

2829
%% Exported to be used by various rabbit_db_* modules
2930
-export([
@@ -76,20 +77,6 @@ init() ->
7677
Error
7778
end.
7879

79-
init_finished() ->
80-
%% Used during initialisation by rabbit_logger_exchange_h.erl
81-
%% If an exchange logger is configured, it needs to declare the
82-
%% exchange. For this, it requires the metadata store to be
83-
%% initialised. The initialisation happens on a rabbit boot step,
84-
%% after the second phase of the prelaunch where the logger is
85-
%% configured.
86-
%% Using this persistent term the logger exchange can delay
87-
%% declaring the exchange until the metadata store is ready.
88-
persistent_term:put(?PT_KEY_INIT_FINISHED, true).
89-
90-
is_init_finished() ->
91-
persistent_term:get(?PT_KEY_INIT_FINISHED, false).
92-
9380
pre_init(IsVirgin) ->
9481
Members = rabbit_db_cluster:members(),
9582
OtherMembers = rabbit_nodes:nodes_excl_me(Members),
@@ -120,6 +107,23 @@ init_using_khepri() ->
120107
#{domain => ?RMQLOG_DOMAIN_DB})
121108
end.
122109

110+
init_finished() ->
111+
%% Used during initialisation by rabbit_logger_exchange_h.erl
112+
%% If an exchange logger is configured, it needs to declare the
113+
%% exchange. For this, it requires the metadata store to be
114+
%% initialised. The initialisation happens on a rabbit boot step,
115+
%% after the second phase of the prelaunch where the logger is
116+
%% configured.
117+
%% Using this persistent term the logger exchange can delay
118+
%% declaring the exchange until the metadata store is ready.
119+
persistent_term:put(?PT_KEY_INIT_FINISHED, true).
120+
121+
is_init_finished() ->
122+
persistent_term:get(?PT_KEY_INIT_FINISHED, false).
123+
124+
clear_init_finished() ->
125+
persistent_term:erase(?PT_KEY_INIT_FINISHED).
126+
123127
-spec reset() -> Ret when
124128
Ret :: ok.
125129
%% @doc Resets the database and the node.

0 commit comments

Comments
 (0)