@@ -411,8 +411,18 @@ delete_in_khepri(QueueName, OnlyDurable) ->
411411 rabbit_khepri :transaction (
412412 fun () ->
413413 Path = khepri_queue_path (QueueName ),
414+ UsesUniformWriteRet = try
415+ khepri_tx :does_api_comply_with (uniform_write_ret )
416+ catch
417+ error :undef ->
418+ false
419+ end ,
414420 case khepri_tx_adv :delete (Path ) of
415- {ok , #{data := _ }} ->
421+ {ok , #{Path := #{data := _ }}} when UsesUniformWriteRet ->
422+ % % we want to execute some things, as decided by rabbit_exchange,
423+ % % after the transaction.
424+ rabbit_db_binding :delete_for_destination_in_khepri (QueueName , OnlyDurable );
425+ {ok , #{data := _ }} when not UsesUniformWriteRet ->
416426 % % we want to execute some things, as decided by rabbit_exchange,
417427 % % after the transaction.
418428 rabbit_db_binding :delete_for_destination_in_khepri (QueueName , OnlyDurable );
@@ -607,7 +617,7 @@ update_in_khepri(QName, Fun) ->
607617 Path = khepri_queue_path (QName ),
608618 Ret1 = rabbit_khepri :adv_get (Path ),
609619 case Ret1 of
610- {ok , #{data := Q , payload_version := Vsn }} ->
620+ {ok , #{Path : = #{ data := Q , payload_version := Vsn } }} ->
611621 UpdatePath = khepri_path :combine_with_conditions (
612622 Path , [# if_payload_version {version = Vsn }]),
613623 Q1 = Fun (Q ),
@@ -658,7 +668,7 @@ update_decorators_in_khepri(QName, Decorators) ->
658668 Path = khepri_queue_path (QName ),
659669 Ret1 = rabbit_khepri :adv_get (Path ),
660670 case Ret1 of
661- {ok , #{data := Q1 , payload_version := Vsn }} ->
671+ {ok , #{Path : = #{ data := Q1 , payload_version := Vsn } }} ->
662672 Q2 = amqqueue :set_decorators (Q1 , Decorators ),
663673 UpdatePath = khepri_path :combine_with_conditions (
664674 Path , [# if_payload_version {version = Vsn }]),
@@ -1098,15 +1108,12 @@ delete_transient_in_khepri(FilterFun) ->
10981108 case rabbit_khepri :adv_get_many (PathPattern ) of
10991109 {ok , Props } ->
11001110 Qs = maps :fold (
1101- fun (Path0 , #{data := Q , payload_version := Vsn }, Acc )
1111+ fun (Path , #{data := Q , payload_version := Vsn }, Acc )
11021112 when ? is_amqqueue (Q ) ->
11031113 case FilterFun (Q ) of
11041114 true ->
1105- Path = khepri_path :combine_with_conditions (
1106- Path0 ,
1107- [# if_payload_version {version = Vsn }]),
11081115 QName = amqqueue :get_name (Q ),
1109- [{Path , QName } | Acc ];
1116+ [{Path , Vsn , QName } | Acc ];
11101117 false ->
11111118 Acc
11121119 end
@@ -1125,20 +1132,7 @@ do_delete_transient_queues_in_khepri([], _FilterFun) ->
11251132do_delete_transient_queues_in_khepri (Qs , FilterFun ) ->
11261133 Res = rabbit_khepri :transaction (
11271134 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 )
1135+ do_delete_transient_queues_in_khepri_tx (Qs , [])
11421136 end ),
11431137 case Res of
11441138 {ok , Items } ->
@@ -1152,6 +1146,35 @@ do_delete_transient_queues_in_khepri(Qs, FilterFun) ->
11521146 Error
11531147 end .
11541148
1149+ do_delete_transient_queues_in_khepri_tx ([], Acc ) ->
1150+ {ok , Acc };
1151+ do_delete_transient_queues_in_khepri_tx ([{Path , Vsn , QName } | Rest ], Acc ) ->
1152+ % % Also see `delete_in_khepri/2'.
1153+ VersionedPath = khepri_path :combine_with_conditions (
1154+ Path , [# if_payload_version {version = Vsn }]),
1155+ UsesUniformWriteRet = try
1156+ khepri_tx :does_api_comply_with (uniform_write_ret )
1157+ catch
1158+ error :undef ->
1159+ false
1160+ end ,
1161+ case khepri_tx_adv :delete (VersionedPath ) of
1162+ {ok , #{Path := #{data := _ }}} when UsesUniformWriteRet ->
1163+ Deletions = rabbit_db_binding :delete_for_destination_in_khepri (
1164+ QName , false ),
1165+ Acc1 = [{QName , Deletions } | Acc ],
1166+ do_delete_transient_queues_in_khepri_tx (Rest , Acc1 );
1167+ {ok , #{data := _ }} when not UsesUniformWriteRet ->
1168+ Deletions = rabbit_db_binding :delete_for_destination_in_khepri (
1169+ QName , false ),
1170+ Acc1 = [{QName , Deletions } | Acc ],
1171+ do_delete_transient_queues_in_khepri_tx (Rest , Acc1 );
1172+ {ok , _ } ->
1173+ do_delete_transient_queues_in_khepri_tx (Rest , Acc );
1174+ {error , _ } = Error ->
1175+ Error
1176+ end .
1177+
11551178% % -------------------------------------------------------------------
11561179% % foreach_transient().
11571180% % -------------------------------------------------------------------
0 commit comments