Skip to content

rabbit_feature_flags: Reset the registry before the boot-time init #8749

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

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions deps/rabbit/src/rabbit_deprecated_features.erl
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ is_permitted_in_configuration(FeatureName, Default) ->
Settings = application:get_env(rabbit, permit_deprecated_features, #{}),
case maps:get(FeatureName, Settings, undefined) of
undefined ->
?LOG_DEBUG(
"Deprecated features: `~ts`: `permit_deprecated_features` "
"map unset in configuration, using default",
[FeatureName],
#{domain => ?RMQLOG_DOMAIN_FEAT_FLAGS}),
Default;
Default ->
PermittedStr = case Default of
Expand Down
15 changes: 14 additions & 1 deletion deps/rabbit/src/rabbit_ff_registry_factory.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
initialize_registry/1,
initialize_registry/3,
acquire_state_change_lock/0,
release_state_change_lock/0]).
release_state_change_lock/0,
reset_registry/0]).

-ifdef(TEST).
-export([registry_loading_lock/0,
Expand Down Expand Up @@ -784,3 +785,15 @@ do_purge_old_registry(Mod) ->
true -> ok;
false -> do_purge_old_registry(Mod)
end.

-spec reset_registry() -> ok.

reset_registry() ->
?LOG_DEBUG(
"Feature flags: resetting loaded registry",
[],
#{domain => ?RMQLOG_DOMAIN_FEAT_FLAGS}),
_ = code:purge(rabbit_ff_registry),
_ = code:delete(rabbit_ff_registry),
?assertNot(rabbit_ff_registry:is_registry_initialized()),
ok.
7 changes: 7 additions & 0 deletions deps/rabbit/src/rabbit_prelaunch_feature_flags.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ setup(#{feature_flags_file := FFFile}) ->
#{domain => ?RMQLOG_DOMAIN_PRELAUNCH}),
case filelib:ensure_dir(FFFile) of
ok ->
%% On boot, we know that there should be no registry loaded at
%% first. There could be a loaded registry around during a
%% stop_app/start_app, so reset it here. This ensures that e.g.
%% any change to the configuration file w.r.t. deprecated features
%% are taken into account.
rabbit_ff_registry_factory:reset_registry(),

?LOG_DEBUG(
"Initializing feature flags registry", [],
#{domain => ?RMQLOG_DOMAIN_PRELAUNCH}),
Expand Down