@@ -411,8 +411,18 @@ delete_in_khepri(QueueName, OnlyDurable) ->
411
411
rabbit_khepri :transaction (
412
412
fun () ->
413
413
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 ,
414
420
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 ->
416
426
% % we want to execute some things, as decided by rabbit_exchange,
417
427
% % after the transaction.
418
428
rabbit_db_binding :delete_for_destination_in_khepri (QueueName , OnlyDurable );
@@ -607,7 +617,7 @@ update_in_khepri(QName, Fun) ->
607
617
Path = khepri_queue_path (QName ),
608
618
Ret1 = rabbit_khepri :adv_get (Path ),
609
619
case Ret1 of
610
- {ok , #{data := Q , payload_version := Vsn }} ->
620
+ {ok , #{Path : = #{ data := Q , payload_version := Vsn } }} ->
611
621
UpdatePath = khepri_path :combine_with_conditions (
612
622
Path , [# if_payload_version {version = Vsn }]),
613
623
Q1 = Fun (Q ),
@@ -658,7 +668,7 @@ update_decorators_in_khepri(QName, Decorators) ->
658
668
Path = khepri_queue_path (QName ),
659
669
Ret1 = rabbit_khepri :adv_get (Path ),
660
670
case Ret1 of
661
- {ok , #{data := Q1 , payload_version := Vsn }} ->
671
+ {ok , #{Path : = #{ data := Q1 , payload_version := Vsn } }} ->
662
672
Q2 = amqqueue :set_decorators (Q1 , Decorators ),
663
673
UpdatePath = khepri_path :combine_with_conditions (
664
674
Path , [# if_payload_version {version = Vsn }]),
@@ -1098,15 +1108,12 @@ delete_transient_in_khepri(FilterFun) ->
1098
1108
case rabbit_khepri :adv_get_many (PathPattern ) of
1099
1109
{ok , Props } ->
1100
1110
Qs = maps :fold (
1101
- fun (Path0 , #{data := Q , payload_version := Vsn }, Acc )
1111
+ fun (Path , #{data := Q , payload_version := Vsn }, Acc )
1102
1112
when ? is_amqqueue (Q ) ->
1103
1113
case FilterFun (Q ) of
1104
1114
true ->
1105
- Path = khepri_path :combine_with_conditions (
1106
- Path0 ,
1107
- [# if_payload_version {version = Vsn }]),
1108
1115
QName = amqqueue :get_name (Q ),
1109
- [{Path , QName } | Acc ];
1116
+ [{Path , Vsn , QName } | Acc ];
1110
1117
false ->
1111
1118
Acc
1112
1119
end
@@ -1125,20 +1132,7 @@ do_delete_transient_queues_in_khepri([], _FilterFun) ->
1125
1132
do_delete_transient_queues_in_khepri (Qs , FilterFun ) ->
1126
1133
Res = rabbit_khepri :transaction (
1127
1134
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 , [])
1142
1136
end ),
1143
1137
case Res of
1144
1138
{ok , Items } ->
@@ -1152,6 +1146,35 @@ do_delete_transient_queues_in_khepri(Qs, FilterFun) ->
1152
1146
Error
1153
1147
end .
1154
1148
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
+
1155
1178
% % -------------------------------------------------------------------
1156
1179
% % foreach_transient().
1157
1180
% % -------------------------------------------------------------------
0 commit comments