diff options
| author | Diana Corbacho <diana@rabbitmq.com> | 2018-08-23 10:15:45 +0100 |
|---|---|---|
| committer | Diana Corbacho <diana@rabbitmq.com> | 2018-08-23 10:15:45 +0100 |
| commit | 5967eab265d4de0c703ea5c5cfc90e88c81f9047 (patch) | |
| tree | caa5d03a7595556cf8b8b5812320e8e90137606a | |
| parent | ee77a09eb44447bbc9c3d75a9e1c07f44b0248a2 (diff) | |
| download | rabbitmq-server-git-5967eab265d4de0c703ea5c5cfc90e88c81f9047.tar.gz | |
Use process status to pass the auto_delete flag
Using a terminate reason makes the channel crash
[#159483364]
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 2220c82b6b..334980bf49 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -287,15 +287,16 @@ terminate({shutdown, missing_owner} = Reason, State) -> terminate({shutdown, _} = R, State = #q{backing_queue = BQ}) -> rabbit_core_metrics:queue_deleted(qname(State)), terminate_shutdown(fun (BQS) -> BQ:terminate(R, BQS) end, State); -terminate(normal, State) -> %% delete case - terminate_shutdown(terminate_delete(true, normal, State), State); -terminate(auto_delete, State) -> %% auto_delete case +terminate(normal, State = #q{status = {terminated_by, auto_delete}}) -> + %% auto_delete case %% To increase performance we want to avoid a mnesia_sync:sync call %% after every transaction, as we could be deleting simultaneously %% thousands of queues. A optimisation introduced by server#1513 %% needs to be reverted by this case, avoiding to guard the delete %% operation on `rabbit_durable_queue` terminate_shutdown(terminate_delete(true, auto_delete, State), State); +terminate(normal, State) -> %% delete case + terminate_shutdown(terminate_delete(true, normal, State), State); %% If we crashed don't try to clean up the BQS, probably best to leave it. terminate(_Reason, State = #q{q = Q}) -> terminate_shutdown(fun (BQS) -> @@ -328,11 +329,13 @@ terminate_delete(EmitStats, Reason0, %% don't care if the internal delete doesn't return 'ok'. rabbit_amqqueue:internal_delete(QName, ActingUser, Reason0) catch - {error, Reason} -> error(Reason) + {error, ReasonE} -> error(ReasonE) end, BQS1 end. +terminated_by({terminated_by, auto_delete}) -> + ?INTERNAL_USER; terminated_by({terminated_by, ActingUser}) -> ActingUser; terminated_by(_) -> @@ -1178,7 +1181,7 @@ handle_call({notify_down, ChPid}, _From, State) -> %% gen_server2 *before* the reply is sent. case handle_ch_down(ChPid, State) of {ok, State1} -> reply(ok, State1); - {stop, State1} -> {stop, auto_delete, ok, State1} + {stop, State1} -> stop(ok, State1#q{status = {terminated_by, auto_delete}}) end; handle_call({basic_get, ChPid, NoAck, LimiterPid}, _From, |
