@@ -145,7 +145,7 @@ recover_semi_durable_route(Gatherer, R = #route{binding = B}, ToRecover) ->
145
145
recover_semi_durable_route_txn (R = # route {binding = B }, X ) ->
146
146
rabbit_misc :execute_mnesia_transaction (
147
147
fun () ->
148
- case mnesia :match_object (rabbit_semi_durable_route , R , read ) of
148
+ case mnesia :read (rabbit_semi_durable_route , B , read ) of
149
149
[] -> no_recover ;
150
150
_ -> ok = sync_transient_route (R , fun mnesia :write /3 ),
151
151
rabbit_exchange :serial (X )
@@ -232,7 +232,7 @@ remove(Src, Dst, B, ActingUser) ->
232
232
lock_resource (Src ),
233
233
lock_resource (Dst ),
234
234
ok = sync_route (# route {binding = B }, durable (Src ), durable (Dst ),
235
- fun mnesia : delete_object /3 ),
235
+ fun delete /3 ),
236
236
Deletions = maybe_auto_delete (
237
237
B # binding .source , [B ], new_deletions (), false ),
238
238
process_deletions (Deletions , ActingUser ).
@@ -319,8 +319,8 @@ remove_for_source(SrcName) ->
319
319
Match = # route {binding = # binding {source = SrcName , _ = '_' }},
320
320
remove_routes (
321
321
lists :usort (
322
- mnesia :match_object (rabbit_route , Match , read ) ++
323
- mnesia :match_object (rabbit_semi_durable_route , Match , read ))).
322
+ mnesia :dirty_match_object (rabbit_route , Match ) ++
323
+ mnesia :dirty_match_object (rabbit_semi_durable_route , Match ))).
324
324
325
325
remove_for_destination (DstName , OnlyDurable ) ->
326
326
remove_for_destination (DstName , OnlyDurable , fun remove_routes /1 ).
@@ -406,21 +406,33 @@ remove_routes(Routes) ->
406
406
% % This partitioning allows us to suppress unnecessary delete
407
407
% % operations on disk tables, which require an fsync.
408
408
{RamRoutes , DiskRoutes } =
409
- lists :partition (fun (R ) -> mnesia :match_object (
410
- rabbit_durable_route , R , read ) == [] end ,
409
+ lists :partition (fun (R ) -> mnesia :read (
410
+ rabbit_durable_route , R # route . binding , read ) == [] end ,
411
411
Routes ),
412
+ {RamOnlyRoutes , SemiDurableRoutes } =
413
+ lists :partition (fun (R ) -> mnesia :read (
414
+ rabbit_semi_durable_route , R # route .binding , read ) == [] end ,
415
+ RamRoutes ),
412
416
% % Of course the destination might not really be durable but it's
413
417
% % just as easy to try to delete it from the semi-durable table
414
418
% % than check first
415
- [ok = sync_route (R , false , true , fun mnesia :delete_object /3 ) ||
416
- R <- RamRoutes ],
417
- [ok = sync_route (R , true , true , fun mnesia :delete_object /3 ) ||
419
+ [ok = sync_route (R , true , true , fun delete /3 ) ||
418
420
R <- DiskRoutes ],
421
+ [ok = sync_route (R , false , true , fun delete /3 ) ||
422
+ R <- SemiDurableRoutes ],
423
+ [ok = sync_route (R , false , false , fun delete /3 ) ||
424
+ R <- RamOnlyRoutes ],
419
425
[R # route .binding || R <- Routes ].
420
426
427
+
428
+ delete (Tab , # route {binding = B }, LockKind ) ->
429
+ mnesia :delete (Tab , B , LockKind );
430
+ delete (Tab , # reverse_route {reverse_binding = B }, LockKind ) ->
431
+ mnesia :delete (Tab , B , LockKind ).
432
+
421
433
remove_transient_routes (Routes ) ->
422
434
[begin
423
- ok = sync_transient_route (R , fun mnesia : delete_object /3 ),
435
+ ok = sync_transient_route (R , fun delete /3 ),
424
436
R # route .binding
425
437
end || R <- Routes ].
426
438
@@ -431,13 +443,13 @@ remove_for_destination(DstName, OnlyDurable, Fun) ->
431
443
Routes = case OnlyDurable of
432
444
false ->
433
445
[reverse_route (R ) ||
434
- R <- mnesia :match_object (
435
- rabbit_reverse_route , MatchRev , read )];
446
+ R <- mnesia :dirty_match_object (
447
+ rabbit_reverse_route , MatchRev )];
436
448
true -> lists :usort (
437
- mnesia :match_object (
438
- rabbit_durable_route , MatchFwd , read ) ++
439
- mnesia :match_object (
440
- rabbit_semi_durable_route , MatchFwd , read ))
449
+ mnesia :dirty_match_object (
450
+ rabbit_durable_route , MatchFwd ) ++
451
+ mnesia :dirty_match_object (
452
+ rabbit_semi_durable_route , MatchFwd ))
441
453
end ,
442
454
Bindings = Fun (Routes ),
443
455
group_bindings_fold (fun maybe_auto_delete /4 , new_deletions (),
0 commit comments