diff options
| -rwxr-xr-x | scripts/rabbitmq-server | 2 | ||||
| -rw-r--r-- | src/rabbit.erl | 12 | ||||
| -rw-r--r-- | src/rabbit_autoheal.erl | 21 | ||||
| -rw-r--r-- | src/rabbit_msg_store.erl | 7 |
4 files changed, 34 insertions, 8 deletions
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server index b430eec3fa..72811adc7b 100755 --- a/scripts/rabbitmq-server +++ b/scripts/rabbitmq-server @@ -81,6 +81,8 @@ case "$(uname -s)" in fi esac +export RABBITMQ_CONFIG_FILE + RABBITMQ_EBIN_ROOT="${RABBITMQ_HOME}/ebin" if ! ${ERL_DIR}erl -pa "$RABBITMQ_EBIN_ROOT" \ -boot "${CLEAN_BOOT_FILE}" \ diff --git a/src/rabbit.erl b/src/rabbit.erl index c703fedb35..062b935507 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -867,11 +867,15 @@ home_dir() -> end. config_files() -> + Abs = fun (F) -> + filename:absname(filename:rootname(F, ".config") ++ ".config") + end, case init:get_argument(config) of - {ok, Files} -> [filename:absname( - filename:rootname(File, ".config") ++ ".config") || - [File] <- Files]; - error -> [] + {ok, Files} -> [Abs(File) || [File] <- Files]; + error -> case os:getenv("RABBITMQ_CONFIG_FILE") of + false -> []; + File -> [Abs(File) ++ " (not found)"] + end end. %% We don't want this in fhc since it references rabbit stuff. And we can't put diff --git a/src/rabbit_autoheal.erl b/src/rabbit_autoheal.erl index 3aa32c09a6..986e3bcda7 100644 --- a/src/rabbit_autoheal.erl +++ b/src/rabbit_autoheal.erl @@ -89,6 +89,12 @@ rabbit_down(Node, {winner_waiting, [Node], Notify}) -> rabbit_down(Node, {winner_waiting, WaitFor, Notify}) -> {winner_waiting, WaitFor -- [Node], Notify}; +rabbit_down(Node, {leader_waiting, [Node]}) -> + not_healing; + +rabbit_down(Node, {leader_waiting, WaitFor}) -> + {leader_waiting, WaitFor -- [Node]}; + rabbit_down(_Node, State) -> %% ignore, we already cancelled the autoheal process State. @@ -121,10 +127,21 @@ handle_msg({request_start, Node}, " * Winner: ~p~n" " * Losers: ~p~n", [AllPartitions, Winner, Losers]), - send(Winner, {become_winner, Losers}), [send(L, {winner_is, Winner}) || L <- Losers], - not_healing + Continue = fun(Msg) -> + handle_msg(Msg, not_healing, Partitions) + end, + case node() =:= Winner of + true -> Continue({become_winner, Losers}); + false -> send(Winner, {become_winner, Losers}), %% [0] + case lists:member(node(), Losers) of + true -> Continue({winner_is, Winner}); + false -> {leader_waiting, Losers} + end + end end; +%% [0] If we are a loser we will never receive this message - but it +%% won't stick in the mailbox as we are restarting anyway handle_msg({request_start, Node}, State, _Partitions) -> diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index 9a4439a732..1562050c0e 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -781,6 +781,7 @@ handle_call({new_client_state, CRef, CPid, MsgOnDiskFun, CloseFDsFun}, _From, clients = Clients, gc_pid = GCPid }) -> Clients1 = dict:store(CRef, {CPid, MsgOnDiskFun, CloseFDsFun}, Clients), + erlang:monitor(process, CPid), reply({IndexState, IndexModule, Dir, GCPid, FileHandlesEts, FileSummaryEts, CurFileCacheEts, FlyingEts}, State #msstate { clients = Clients1 }); @@ -804,8 +805,6 @@ handle_cast({client_dying, CRef}, handle_cast({client_delete, CRef}, State = #msstate { clients = Clients }) -> - {CPid, _, _} = dict:fetch(CRef, Clients), - credit_flow:peer_down(CPid), State1 = State #msstate { clients = dict:erase(CRef, Clients) }, noreply(remove_message(CRef, CRef, clear_client(CRef, State1))); @@ -888,6 +887,10 @@ handle_info(sync, State) -> handle_info(timeout, State) -> noreply(internal_sync(State)); +handle_info({'DOWN', _MRef, process, Pid, _Reason}, State) -> + credit_flow:peer_down(Pid), + noreply(State); + handle_info({'EXIT', _Pid, Reason}, State) -> {stop, Reason, State}. |
