diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-08-28 15:13:00 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-08-28 15:13:00 +0100 |
| commit | c3638834b1d6b4bd706686860b1dcde6af54a954 (patch) | |
| tree | a8e445d7e4c63b78641127fb32d70f26065108cc | |
| parent | 4bb858953e0ab08cf9721b90b521ed50c19b65c8 (diff) | |
| download | rabbitmq-server-git-c3638834b1d6b4bd706686860b1dcde6af54a954.tar.gz | |
dq: revert the table change to earlier on, so that recovery isn't as horrendously slow. amqq_proc: correct order of actions in delete_queue and document.
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 10 | ||||
| -rw-r--r-- | src/rabbit_disk_queue.erl | 20 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 9d97e881ac..45f311f752 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -122,8 +122,14 @@ terminate(_Reason, State) -> %% FIXME: How do we cancel active subscriptions? State1 = stop_memory_timer(State), QName = qname(State1), - ok = rabbit_amqqueue:internal_delete(QName), - {ok, _MS} = rabbit_mixed_queue:delete_queue(State1 #q.mixed_state). + %% Delete from disk queue first. If we crash at this point, when a + %% durable queue, we will be recreated at startup, possibly with + %% partial content. The alternative is much worse however - if we + %% called internal_delete first, we would then have a race between + %% the disk_queue delete and a new queue with the same name being + %% created and published to. + {ok, _MS} = rabbit_mixed_queue:delete_queue(State1 #q.mixed_state), + ok = rabbit_amqqueue:internal_delete(QName). code_change(_OldVsn, State, _Extra) -> {ok, State}. diff --git a/src/rabbit_disk_queue.erl b/src/rabbit_disk_queue.erl index 0ff4c50e73..28e74537bf 100644 --- a/src/rabbit_disk_queue.erl +++ b/src/rabbit_disk_queue.erl @@ -381,6 +381,17 @@ init([FileSizeLimit, ReadFileHandlesLimit]) -> ok = rabbit_memory_manager:register (self(), true, rabbit_disk_queue, set_mode, []), ok = filelib:ensure_dir(form_filename("nothing")), + + Node = node(), + ok = + case mnesia:change_table_copy_type(rabbit_disk_queue, Node, + disc_copies) of + {atomic, ok} -> ok; + {aborted, {already_exists, rabbit_disk_queue, Node, + disc_copies}} -> ok; + E -> E + end, + file:delete(form_filename(atom_to_list(?MSG_LOC_NAME) ++ ?FILE_EXTENSION_DETS)), {ok, MsgLocationDets} = @@ -429,15 +440,6 @@ init([FileSizeLimit, ReadFileHandlesLimit]) -> {ok, State1 = #dqstate { current_file_name = CurrentName, current_offset = Offset } } = load_from_disk(State), - Node = node(), - ok = - case mnesia:change_table_copy_type(rabbit_disk_queue, Node, - disc_copies) of - {atomic, ok} -> ok; - {aborted, {already_exists, rabbit_disk_queue, Node, - disc_copies}} -> ok; - E -> E - end, %% read is only needed so that we can seek {ok, FileHdl} = file:open(form_filename(CurrentName), [read, write, raw, binary, delayed_write]), |
