Skip to content

Use process status to pass the auto_delete flag #1681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/rabbit_amqqueue_process.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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(_) ->
Expand Down Expand Up @@ -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,
Expand Down