Skip to content

Commit 7a4ccb4

Browse files
committed
rabbit_feature_flags: Drop the -on_load() directive
We used it to prevent a node breakage when RabbitMQ was updated from e.g. 3.6.x to 3.7.0 when the package manager uncompresses the files of the package while the service is running, overwriting existing files. In this situation, a 3.6.x node could be queried for its feature flags state and the `rabbit_feature_flags` module would be loaded (because it appeared during the upgrade but before the restart) and this would fail because the node really didn't support feature flags. With some feature flags being required as of RabbitMQ 3.11.0, upgrading directly from e.g. 3.6.x is unsupported now. Therefore, we can drop this `-on_load()` failsafe.
1 parent d54f7cb commit 7a4ccb4

File tree

1 file changed

+0
-62
lines changed

1 file changed

+0
-62
lines changed

deps/rabbit/src/rabbit_feature_flags.erl

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@
360360
inventory/0,
361361
cluster_inventory/0]).
362362

363-
-on_load(on_load/0).
364-
365363
-spec list() -> feature_flags().
366364
%% @doc
367365
%% Lists all supported feature flags.
@@ -1243,63 +1241,3 @@ sync_feature_flags_with_cluster(_Nodes, _NodeIsVirgin) ->
12431241

12441242
refresh_feature_flags_after_app_load() ->
12451243
rabbit_ff_controller:refresh_after_app_load().
1246-
1247-
on_load() ->
1248-
%% The goal of this `on_load()` code server hook is to prevent this
1249-
%% module from being loaded in an already running RabbitMQ node if
1250-
%% the running version does not have the feature flags subsystem.
1251-
%%
1252-
%% This situation happens when an upgrade overwrites RabbitMQ files
1253-
%% with the node still running. This is the case with many packages:
1254-
%% files are updated on disk, then a post-install step takes care of
1255-
%% restarting the service.
1256-
%%
1257-
%% The problem is that if many nodes in a cluster are updated at the
1258-
%% same time, one node running the newer version might query feature
1259-
%% flags on an old node where this module is already available
1260-
%% (because files were already overwritten). This causes the query
1261-
%% to report an unexpected answer and the newer node to refuse to
1262-
%% start.
1263-
%%
1264-
%% However, when the module is executed outside of RabbitMQ (for
1265-
%% debugging purpose or in the context of EUnit for instance), we
1266-
%% want to allow the load. That's why we first check if RabbitMQ is
1267-
%% actually running.
1268-
case rabbit:is_running() of
1269-
true ->
1270-
%% RabbitMQ is running.
1271-
%%
1272-
%% Now we want to differentiate a pre-feature-flags node
1273-
%% from one having the subsystem.
1274-
%%
1275-
%% To do that, we verify if the `feature_flags_file`
1276-
%% application environment variable is defined. With a
1277-
%% feature-flags-enabled node, this application environment
1278-
%% variable is defined by rabbitmq-server(8).
1279-
case application:get_env(rabbit, feature_flags_file) of
1280-
{ok, _} ->
1281-
%% This is a feature-flags-enabled version. Loading
1282-
%% the module is permitted.
1283-
ok;
1284-
_ ->
1285-
%% This is a pre-feature-flags version. We deny the
1286-
%% load and report why, possibly specifying the
1287-
%% version of RabbitMQ.
1288-
Vsn = case application:get_key(rabbit, vsn) of
1289-
{ok, V} -> V;
1290-
undefined -> "unknown version"
1291-
end,
1292-
"Refusing to load '" ?MODULE_STRING "' on this "
1293-
"node. It appears to be running a pre-feature-flags "
1294-
"version of RabbitMQ (" ++ Vsn ++ "). This is fine: "
1295-
"a newer version of RabbitMQ was deployed on this "
1296-
"node, but it was not restarted yet. This warning "
1297-
"is probably caused by a remote node querying this "
1298-
"node for its feature flags."
1299-
end;
1300-
false ->
1301-
%% RabbitMQ is not running. Loading the module is permitted
1302-
%% because this Erlang node will never be queried for its
1303-
%% feature flags.
1304-
ok
1305-
end.

0 commit comments

Comments
 (0)