diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-08-20 15:02:02 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-08-20 15:02:02 +0100 |
commit | f1c0c943194a6bfb8503a38e1dbf15382ab0e0ff (patch) | |
tree | ccc4e1eadfe39e7092819b5e90e1287817395c59 | |
parent | 9d592379afcc7b67f0d1d5c8e7789ad0049a979f (diff) | |
download | rabbitmq-server-f1c0c943194a6bfb8503a38e1dbf15382ab0e0ff.tar.gz |
Allow crashing queue processes to come back as slaves if that's what we need.
-rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 1 | ||||
-rw-r--r-- | src/rabbit_queue_index.erl | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index c8bff0c4..0c9e6c21 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -116,6 +116,7 @@ init_slave(Q = #amqqueue{name = QName}) -> Self, {rabbit_amqqueue, set_ram_duration_target, [Self]}), {ok, BQ} = application:get_env(backing_queue_module), Q1 = Q #amqqueue { pid = QPid }, + ok = rabbit_queue_index:erase(QName), %% For crash recovery BQS = bq_init(BQ, Q1, new), State = #state { q = Q1, gm = GM, diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index 0f572866..f21b44bc 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -16,7 +16,7 @@ -module(rabbit_queue_index). --export([init/2, recover/5, +-export([erase/1, init/2, recover/5, terminate/2, delete_and_terminate/1, publish/5, deliver/2, ack/2, sync/1, needs_sync/1, flush/1, read/3, next_segment_boundary/1, bounds/1, start/1, stop/0]). @@ -200,6 +200,7 @@ {rabbit_types:msg_id(), non_neg_integer(), A})). -type(shutdown_terms() :: [term()] | 'non_clean_shutdown'). +-spec(erase/1 :: (rabbit_amqqueue:name()) -> 'ok'). -spec(init/2 :: (rabbit_amqqueue:name(), on_sync_fun()) -> qistate()). -spec(recover/5 :: (rabbit_amqqueue:name(), shutdown_terms(), boolean(), contains_predicate(), on_sync_fun()) -> @@ -233,6 +234,13 @@ %% public API %%---------------------------------------------------------------------------- +erase(Name) -> + #qistate { dir = Dir } = blank_state(Name), + case rabbit_file:is_dir(Dir) of + true -> rabbit_file:recursive_delete([Dir]); + false -> ok + end. + init(Name, OnSyncFun) -> State = #qistate { dir = Dir } = blank_state(Name), false = rabbit_file:is_file(Dir), %% is_file == is file or dir |