@@ -287,15 +287,16 @@ terminate({shutdown, missing_owner} = Reason, State) ->
287
287
terminate ({shutdown , _ } = R , State = # q {backing_queue = BQ }) ->
288
288
rabbit_core_metrics :queue_deleted (qname (State )),
289
289
terminate_shutdown (fun (BQS ) -> BQ :terminate (R , BQS ) end , State );
290
- terminate (normal , State ) -> % % delete case
291
- terminate_shutdown (terminate_delete (true , normal , State ), State );
292
- terminate (auto_delete , State ) -> % % auto_delete case
290
+ terminate (normal , State = # q {status = {terminated_by , auto_delete }}) ->
291
+ % % auto_delete case
293
292
% % To increase performance we want to avoid a mnesia_sync:sync call
294
293
% % after every transaction, as we could be deleting simultaneously
295
294
% % thousands of queues. A optimisation introduced by server#1513
296
295
% % needs to be reverted by this case, avoiding to guard the delete
297
296
% % operation on `rabbit_durable_queue`
298
297
terminate_shutdown (terminate_delete (true , auto_delete , State ), State );
298
+ terminate (normal , State ) -> % % delete case
299
+ terminate_shutdown (terminate_delete (true , normal , State ), State );
299
300
% % If we crashed don't try to clean up the BQS, probably best to leave it.
300
301
terminate (_Reason , State = # q {q = Q }) ->
301
302
terminate_shutdown (fun (BQS ) ->
@@ -328,11 +329,13 @@ terminate_delete(EmitStats, Reason0,
328
329
% % don't care if the internal delete doesn't return 'ok'.
329
330
rabbit_amqqueue :internal_delete (QName , ActingUser , Reason0 )
330
331
catch
331
- {error , Reason } -> error (Reason )
332
+ {error , ReasonE } -> error (ReasonE )
332
333
end ,
333
334
BQS1
334
335
end .
335
336
337
+ terminated_by ({terminated_by , auto_delete }) ->
338
+ ? INTERNAL_USER ;
336
339
terminated_by ({terminated_by , ActingUser }) ->
337
340
ActingUser ;
338
341
terminated_by (_ ) ->
@@ -1178,7 +1181,7 @@ handle_call({notify_down, ChPid}, _From, State) ->
1178
1181
% % gen_server2 *before* the reply is sent.
1179
1182
case handle_ch_down (ChPid , State ) of
1180
1183
{ok , State1 } -> reply (ok , State1 );
1181
- {stop , State1 } -> { stop , auto_delete , ok , State1 }
1184
+ {stop , State1 } -> stop ( ok , State1 # q { status = { terminated_by , auto_delete }})
1182
1185
end ;
1183
1186
1184
1187
handle_call ({basic_get , ChPid , NoAck , LimiterPid }, _From ,
0 commit comments