@@ -289,6 +289,13 @@ terminate({shutdown, _} = R, State = #q{backing_queue = BQ}) ->
289
289
terminate_shutdown (fun (BQS ) -> BQ :terminate (R , BQS ) end , State );
290
290
terminate (normal , State ) -> % % delete case
291
291
terminate_shutdown (terminate_delete (true , normal , State ), State );
292
+ terminate (auto_delete , State ) -> % % auto_delete case
293
+ % % To increase performance we want to avoid a mnesia_sync:sync call
294
+ % % after every transaction, as we could be deleting simultaneously
295
+ % % thousands of queues. A optimisation introduced by server#1513
296
+ % % needs to be reverted by this case, avoiding to guard the delete
297
+ % % operation on `rabbit_durable_queue`
298
+ terminate_shutdown (terminate_delete (true , auto_delete , State ), State );
292
299
% % If we crashed don't try to clean up the BQS, probably best to leave it.
293
300
terminate (_Reason , State = # q {q = Q }) ->
294
301
terminate_shutdown (fun (BQS ) ->
@@ -300,12 +307,16 @@ terminate(_Reason, State = #q{q = Q}) ->
300
307
BQS
301
308
end , State ).
302
309
303
- terminate_delete (EmitStats , Reason ,
310
+ terminate_delete (EmitStats , Reason0 ,
304
311
State = # q {q = # amqqueue {name = QName },
305
312
backing_queue = BQ ,
306
313
status = Status }) ->
307
314
ActingUser = terminated_by (Status ),
308
315
fun (BQS ) ->
316
+ Reason = case Reason0 of
317
+ auto_delete -> normal ;
318
+ Any -> Any
319
+ end ,
309
320
BQS1 = BQ :delete_and_terminate (Reason , BQS ),
310
321
if EmitStats -> rabbit_event :if_enabled (State , # q .stats_timer ,
311
322
fun () -> emit_stats (State ) end );
@@ -315,7 +326,7 @@ terminate_delete(EmitStats, Reason,
315
326
% % logged.
316
327
try
317
328
% % don't care if the internal delete doesn't return 'ok'.
318
- rabbit_amqqueue :internal_delete (QName , ActingUser )
329
+ rabbit_amqqueue :internal_delete (QName , ActingUser , Reason0 )
319
330
catch
320
331
{error , Reason } -> error (Reason )
321
332
end ,
@@ -1167,7 +1178,7 @@ handle_call({notify_down, ChPid}, _From, State) ->
1167
1178
% % gen_server2 *before* the reply is sent.
1168
1179
case handle_ch_down (ChPid , State ) of
1169
1180
{ok , State1 } -> reply (ok , State1 );
1170
- {stop , State1 } -> stop ( ok , State1 )
1181
+ {stop , State1 } -> { stop , auto_delete , ok , State1 }
1171
1182
end ;
1172
1183
1173
1184
handle_call ({basic_get , ChPid , NoAck , LimiterPid }, _From ,
0 commit comments