summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2019-10-07 12:01:32 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2019-10-07 12:01:32 +0200
commitfbdef3c51acbc8d221e734f9f29683ba38a01250 (patch)
treee7b05eeef0aae0b481d112812f4e71936f8f8274 /src
parent0332d2e30bc2498ed81c4d65b399b183e2cfa96c (diff)
downloadrabbitmq-server-git-fbdef3c51acbc8d221e734f9f29683ba38a01250.tar.gz
rabbit_feature_flags: Prevent load of the module on pre-feature-flags nodes
In a cluster, if e.g. RabbitMQ 3.7.17 packages are deployed on all cluster member, but the nodes are not restarted yet, the first node to restart will fail. The reason is that the `rabbit_feature_flags` module is available on all nodes after the package deployment. However, the module may be loaded in a pre-feature-flags already running node. In this unexpected context, the module fails to respond properly to the queries of the remote restarting node. To fix this, we use an `on_lod()` hook to prevent this module from being loaded by the Erlang code server if the context is unexpected. This will cause the query to abort with an undefined function call, exactly like if the module was missing. Fixes #2132.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_feature_flags.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rabbit_feature_flags.erl b/src/rabbit_feature_flags.erl
index cdf9090cf0..9591cd691d 100644
--- a/src/rabbit_feature_flags.erl
+++ b/src/rabbit_feature_flags.erl
@@ -246,6 +246,8 @@
migration_fun/0,
migration_fun_context/0]).
+-on_load(on_load/0).
+
-spec list() -> feature_flags().
%% @doc
%% Lists all supported feature flags.
@@ -2265,3 +2267,15 @@ maybe_enable_locally_after_app_load([FeatureName | Rest]) ->
share_new_feature_flags_after_app_load(FeatureFlags, Timeout) ->
push_local_feature_flags_from_apps_unknown_remotely(
node(), FeatureFlags, Timeout).
+
+on_load() ->
+ case application:get_env(rabbit, feature_flags_file) of
+ {ok, _} ->
+ ok;
+ _ ->
+ "Refusing to load '" ?MODULE_STRING "' in what appears to "
+ "be a pre-feature-flags running node "
+ "(" ++ rabbit_misc:version() ++ "). This is fine: it is "
+ "probably a remote node querying this node for its feature "
+ "flags."
+ end.