diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-10-29 16:18:39 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-10-29 16:18:39 +0000 |
commit | 9540b3b0dcd6c4c4ae4d5db5fae4486ab728c461 (patch) | |
tree | 885764ca04b8b5e32fd3bcad01509517ea2c118e | |
parent | cd4eee76e7bb3ea7065603ca6df33eaeea392a3a (diff) | |
download | rabbitmq-server-9540b3b0dcd6c4c4ae4d5db5fae4486ab728c461.tar.gz |
Attempt to clean up actions when terminating a slave. Slave termination now never deletes a queue.
-rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index b1a86493..33d9e38e 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -293,32 +293,46 @@ handle_info({bump_credit, Msg}, State) -> handle_info(Msg, State) -> {stop, {unexpected_info, Msg}, State}. -%% If the Reason is shutdown, or {shutdown, _}, it is not the queue -%% being deleted: it's just the node going down. Even though we're a -%% slave, we have no idea whether or not we'll be the only copy coming -%% back up. Thus we must assume we will be, and preserve anything we -%% have on disk. terminate(_Reason, #state { backing_queue_state = undefined }) -> %% We've received a delete_and_terminate from gm, thus nothing to %% do here. ok; -terminate({shutdown, dropped} = R, #state { backing_queue = BQ, - backing_queue_state = BQS }) -> +terminate({shutdown, dropped} = R, State = #state{backing_queue = BQ, + backing_queue_state = BQS}) -> %% See rabbit_mirror_queue_master:terminate/2 + %% TODO why not gm:leave()? + terminate_common(State), BQ:delete_and_terminate(R, BQS); -terminate(Reason, #state { q = Q, - gm = GM, - backing_queue = BQ, - backing_queue_state = BQS, - rate_timer_ref = RateTRef }) -> +terminate(shutdown, State) -> + terminate_shutdown(shutdown, State); +terminate({shutdown, _} = R, State) -> + terminate_shutdown(R, State); +terminate(Reason, State = #state{gm = GM, + backing_queue = BQ, + backing_queue_state = BQS}) -> ok = gm:leave(GM), - QueueState = rabbit_amqqueue_process:init_with_backing_queue_state( - Q, BQ, BQS, RateTRef, [], pmon:new(), dict:new()), - rabbit_amqqueue_process:terminate(Reason, QueueState); + terminate_common(State), + BQ:delete_and_terminate(Reason, BQS); terminate([_SPid], _Reason) -> %% gm case ok. +%% If the Reason is shutdown, or {shutdown, _}, it is not the queue +%% being deleted: it's just the node going down. Even though we're a +%% slave, we have no idea whether or not we'll be the only copy coming +%% back up. Thus we must assume we will be, and preserve anything we +%% have on disk. +terminate_shutdown(Reason, State = #state{gm = GM, + backing_queue = BQ, + backing_queue_state = BQS}) -> + ok = gm:leave(GM), + terminate_common(State), + BQ:terminate(Reason, BQS). + +terminate_common(State) -> + ok = rabbit_memory_monitor:deregister(self()), + stop_rate_timer(stop_sync_timer(State)). + code_change(_OldVsn, State, _Extra) -> {ok, State}. |