Skip to content

Commit 902092a

Browse files
author
Loïc Hoguin
committed
Don't debug log when a cache update_counter fails
With recent reworkings of the message store this can fail more often than it did before. That's fine because in that case we will just try again. We don't need to keep the debug log. This only applies to fan-out scenarios.
1 parent 0b92354 commit 902092a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

deps/rabbit/src/rabbit_msg_store.erl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,21 @@ contains_message(MsgId, From, State) ->
12351235

12361236
update_msg_cache(CacheEts, MsgId, Msg) ->
12371237
case ets:insert_new(CacheEts, {MsgId, Msg, 1}) of
1238-
true -> ok;
1239-
false -> rabbit_misc:safe_ets_update_counter(
1240-
CacheEts, MsgId, {3, +1}, fun (_) -> ok end,
1241-
fun () -> update_msg_cache(CacheEts, MsgId, Msg) end)
1238+
true ->
1239+
ok;
1240+
false ->
1241+
%% Note: This is basically rabbit_misc:safe_ets_update_counter/5,
1242+
%% but without the debug log that we don't want as the update is
1243+
%% more likely to fail following recent reworkings.
1244+
try
1245+
ets:update_counter(CacheEts, MsgId, {3, +1}),
1246+
ok
1247+
catch error:badarg ->
1248+
%% The entry must have been removed between
1249+
%% insert_new and update_counter, most likely
1250+
%% due to a file rollover or a confirm. Try again.
1251+
update_msg_cache(CacheEts, MsgId, Msg)
1252+
end
12421253
end.
12431254

12441255
adjust_valid_total_size(File, Delta, State = #msstate {

0 commit comments

Comments
 (0)