diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-03-03 17:14:16 +0100 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-03-03 17:14:16 +0100 |
| commit | 3b3aa4872af7c7baa7d07f22edcadecf7b0a144d (patch) | |
| tree | 08e6f3a9a73c8217b3a2b0c8ccee8c7175010f1d /src | |
| parent | a614670cca2825f94f4b385269279e7ba6c6628f (diff) | |
| download | rabbitmq-server-git-3b3aa4872af7c7baa7d07f22edcadecf7b0a144d.tar.gz | |
rabbit_node_monitor: Cache pause_minority_guard() return value
If the list returned by `nodes()` didn't change since last call to
`pause_minority_guard()`, return the previous state, not `ok`.
This fixes a bug where the first call to `pause_minority_guard()` could
return `pausing` but the subsequent calls would return `ok`, leading to
channels resuming the send of confirms even though the node is about to
enter pause mode.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_node_monitor.erl | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index 82a7a89be9..2fab29996b 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -216,22 +216,24 @@ pause_minority_guard() -> undefined -> {ok, M} = application:get_env(rabbit, cluster_partition_handling), case M of - pause_minority -> pause_minority_guard([]); + pause_minority -> pause_minority_guard([], ok); _ -> put(pause_minority_guard, not_minority_mode), ok end; - {minority_mode, Nodes} -> - pause_minority_guard(Nodes) + {minority_mode, Nodes, LastState} -> + pause_minority_guard(Nodes, LastState) end. -pause_minority_guard(LastNodes) -> +pause_minority_guard(LastNodes, LastState) -> case nodes() of - LastNodes -> ok; - _ -> put(pause_minority_guard, {minority_mode, nodes()}), - case majority() of - false -> pausing; - true -> ok - end + LastNodes -> LastState; + _ -> NewState = case majority() of + false -> pausing; + true -> ok + end, + put(pause_minority_guard, + {minority_mode, nodes(), NewState}), + NewState end. %%---------------------------------------------------------------------------- |
