@@ -412,7 +412,7 @@ delete_in_khepri(QueueName, OnlyDurable) ->
412412 fun () ->
413413 Path = khepri_queue_path (QueueName ),
414414 case khepri_tx_adv :delete (Path ) of
415- {ok , #{data := _ }} ->
415+ {ok , #{Path : = #{ data := _ } }} ->
416416 % % we want to execute some things, as decided by rabbit_exchange,
417417 % % after the transaction.
418418 rabbit_db_binding :delete_for_destination_in_khepri (QueueName , OnlyDurable );
@@ -607,7 +607,7 @@ update_in_khepri(QName, Fun) ->
607607 Path = khepri_queue_path (QName ),
608608 Ret1 = rabbit_khepri :adv_get (Path ),
609609 case Ret1 of
610- {ok , #{data := Q , payload_version := Vsn }} ->
610+ {ok , #{Path : = #{ data := Q , payload_version := Vsn } }} ->
611611 UpdatePath = khepri_path :combine_with_conditions (
612612 Path , [# if_payload_version {version = Vsn }]),
613613 Q1 = Fun (Q ),
@@ -658,7 +658,7 @@ update_decorators_in_khepri(QName, Decorators) ->
658658 Path = khepri_queue_path (QName ),
659659 Ret1 = rabbit_khepri :adv_get (Path ),
660660 case Ret1 of
661- {ok , #{data := Q1 , payload_version := Vsn }} ->
661+ {ok , #{Path : = #{ data := Q1 , payload_version := Vsn } }} ->
662662 Q2 = amqqueue :set_decorators (Q1 , Decorators ),
663663 UpdatePath = khepri_path :combine_with_conditions (
664664 Path , [# if_payload_version {version = Vsn }]),
@@ -1098,15 +1098,12 @@ delete_transient_in_khepri(FilterFun) ->
10981098 case rabbit_khepri :adv_get_many (PathPattern ) of
10991099 {ok , Props } ->
11001100 Qs = maps :fold (
1101- fun (Path0 , #{data := Q , payload_version := Vsn }, Acc )
1101+ fun (Path , #{data := Q , payload_version := Vsn }, Acc )
11021102 when ? is_amqqueue (Q ) ->
11031103 case FilterFun (Q ) of
11041104 true ->
1105- Path = khepri_path :combine_with_conditions (
1106- Path0 ,
1107- [# if_payload_version {version = Vsn }]),
11081105 QName = amqqueue :get_name (Q ),
1109- [{Path , QName } | Acc ];
1106+ [{Path , Vsn , QName } | Acc ];
11101107 false ->
11111108 Acc
11121109 end
@@ -1125,20 +1122,7 @@ do_delete_transient_queues_in_khepri([], _FilterFun) ->
11251122do_delete_transient_queues_in_khepri (Qs , FilterFun ) ->
11261123 Res = rabbit_khepri :transaction (
11271124 fun () ->
1128- rabbit_misc :fold_while_ok (
1129- fun ({Path , QName }, Acc ) ->
1130- % % Also see `delete_in_khepri/2'.
1131- case khepri_tx_adv :delete (Path ) of
1132- {ok , #{data := _ }} ->
1133- Deletions = rabbit_db_binding :delete_for_destination_in_khepri (
1134- QName , false ),
1135- {ok , [{QName , Deletions } | Acc ]};
1136- {ok , _ } ->
1137- {ok , Acc };
1138- {error , _ } = Error ->
1139- Error
1140- end
1141- end , [], Qs )
1125+ do_delete_transient_queues_in_khepri_tx (Qs , [])
11421126 end ),
11431127 case Res of
11441128 {ok , Items } ->
@@ -1152,6 +1136,24 @@ do_delete_transient_queues_in_khepri(Qs, FilterFun) ->
11521136 Error
11531137 end .
11541138
1139+ do_delete_transient_queues_in_khepri_tx ([], Acc ) ->
1140+ {ok , Acc };
1141+ do_delete_transient_queues_in_khepri_tx ([{Path , Vsn , QName } | Rest ], Acc ) ->
1142+ % % Also see `delete_in_khepri/2'.
1143+ VersionedPath = khepri_path :combine_with_conditions (
1144+ Path , [# if_payload_version {version = Vsn }]),
1145+ case khepri_tx_adv :delete (VersionedPath ) of
1146+ {ok , #{Path := #{data := _ }}} ->
1147+ Deletions = rabbit_db_binding :delete_for_destination_in_khepri (
1148+ QName , false ),
1149+ Acc1 = [{QName , Deletions } | Acc ],
1150+ do_delete_transient_queues_in_khepri_tx (Rest , Acc1 );
1151+ {ok , _ } ->
1152+ do_delete_transient_queues_in_khepri_tx (Rest , Acc );
1153+ {error , _ } = Error ->
1154+ Error
1155+ end .
1156+
11551157% % -------------------------------------------------------------------
11561158% % foreach_transient().
11571159% % -------------------------------------------------------------------
0 commit comments