Merge pull request #4759 from rabbitmq/rabbitmq-server-4755

Ensure maintenance mode state table exists after node [re]boot
This commit is contained in:
Michael Klishin 2022-05-08 22:10:04 +04:00 committed by GitHub
commit ec39f83105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 1 deletions

View File

@ -29,7 +29,8 @@
transfer_leadership_of_quorum_queues/1,
transfer_leadership_of_classic_mirrored_queues/1,
status_table_name/0,
status_table_definition/0
status_table_definition/0,
boot/0
]).
-define(TABLE, rabbit_node_maintenance_states).
@ -44,6 +45,38 @@
maintenance_status/0
]).
%%
%% Boot
%%
-rabbit_boot_step({rabbit_maintenance_mode_state,
[{description, "initializes maintenance mode state"},
{mfa, {?MODULE, boot, []}},
{requires, networking}]}).
boot() ->
case rabbit_feature_flags:is_enabled(?FEATURE_FLAG, non_blocking) of
true ->
TableName = status_table_name(),
rabbit_log:info(
"Creating table ~s for feature flag `~s`",
[TableName, ?FEATURE_FLAG]),
try
_ = rabbit_table:create(
TableName,
status_table_definition())
catch throw:Reason ->
rabbit_log:error(
"Failed to create maintenance status table: ~p",
[Reason])
end;
false ->
ok;
state_changing ->
%% feature flag migration will do the job for us
ok
end.
%%
%% API
%%