Skip to content

Commit 69fd9ff

Browse files
committed
Restore safe parts of 0278980 CQ shared store GC improvements
Restore three independent improvements from the reverted commit that are unrelated to the broken current_file_removes mechanism: - Relax index_update_fields assertion: true= -> _= so a missing key does not crash the process - Add prioritise_cast/3 to rabbit_msg_store_gc so delete requests are processed before compaction requests, avoiding unnecessary compaction of files that are already pending deletion - compact_file/2 early-exit guard was already present after the revert
1 parent c4db698 commit 69fd9ff

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

deps/rabbit/src/rabbit_msg_store.erl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,18 +1180,16 @@ remove_message(MsgId, CRef, State = #msstate{ index_ets = IndexEts }) ->
11801180
when RefCount > 0 ->
11811181
%% only update field, otherwise bad interaction with
11821182
%% concurrent GC
1183-
Dec = fun () -> index_update_ref_counter(IndexEts, MsgId, -1) end,
1183+
ok = index_update_ref_counter(IndexEts, MsgId, -1),
11841184
case RefCount of
11851185
%% Don't remove from cur_file_cache_ets here because
11861186
%% there may be further writes in the mailbox for the
11871187
%% same msg.
1188-
1 -> ok = Dec(),
1189-
delete_file_if_empty(
1188+
1 -> delete_file_if_empty(
11901189
File, gc_candidate(File,
11911190
adjust_valid_total_size(
11921191
File, -TotalSize, State)));
1193-
_ -> ok = Dec(),
1194-
gc_candidate(File, State)
1192+
_ -> gc_candidate(File, State)
11951193
end
11961194
end.
11971195

@@ -1656,7 +1654,7 @@ index_update(IndexEts, Obj) ->
16561654
ok.
16571655

16581656
index_update_fields(IndexEts, Key, Updates) ->
1659-
true = ets:update_element(IndexEts, Key, Updates),
1657+
_ = ets:update_element(IndexEts, Key, Updates),
16601658
ok.
16611659

16621660
index_update_ref_counter(IndexEts, Key, RefCount) ->

deps/rabbit/src/rabbit_msg_store_gc.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
-export([start_link/1, compact/2, truncate/4, delete/2, stop/1]).
1313

1414
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
15-
terminate/2, code_change/3]).
15+
terminate/2, code_change/3, prioritise_cast/3]).
1616

1717
-record(state,
1818
{ pending,
@@ -51,6 +51,10 @@ delete(Server, File) ->
5151
stop(Server) ->
5252
gen_server2:call(Server, stop, infinity).
5353

54+
%% TODO replace with priority messages for OTP28+
55+
prioritise_cast({delete, _}, _Len, _State) -> 5;
56+
prioritise_cast(_, _Len, _State) -> 0.
57+
5458
%%----------------------------------------------------------------------------
5559

5660
init([MsgStoreState]) ->

0 commit comments

Comments
 (0)