Skip to content

Commit 1797a6f

Browse files
committed
Don't scan for valid messages when deleting
Looking for valid messages before deleting a message store file was an old check for extra safety. However, it is a bottleneck under intense workload: it can take a few seconds to delete a file (a vast majority of that spent scanning for messages), while new files can be created faster than that. That leads to the disk usage growing, even if the number of messages in the queues is not. We are not aware of any situations where this check actually found valid messages in a file that was requested to be deleted. This is a well tested code path a this point, so let's just remove the extra check.
1 parent 7289487 commit 1797a6f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

deps/rabbit/src/rabbit_msg_store.erl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,9 +2123,9 @@ truncate_file(File, Size, ThresholdTimestamp, #gc_state{ file_summary_ets = File
21232123

21242124
-spec delete_file(non_neg_integer(), gc_state()) -> ok | defer.
21252125

2126-
delete_file(File, State = #gc_state { file_summary_ets = FileSummaryEts,
2127-
file_handles_ets = FileHandlesEts,
2128-
dir = Dir }) ->
2126+
delete_file(File, #gc_state { file_summary_ets = FileSummaryEts,
2127+
file_handles_ets = FileHandlesEts,
2128+
dir = Dir }) ->
21292129
case ets:match_object(FileHandlesEts, {{'_', File}, '_'}, 1) of
21302130
{[_|_], _Cont} ->
21312131
rabbit_log:debug("Asked to delete file ~p but it has active readers. Deferring.",
@@ -2134,7 +2134,6 @@ delete_file(File, State = #gc_state { file_summary_ets = FileSummaryEts,
21342134
_ ->
21352135
[#file_summary{ valid_total_size = 0,
21362136
file_size = FileSize }] = ets:lookup(FileSummaryEts, File),
2137-
[] = scan_and_vacuum_message_file(File, State),
21382137
ok = file:delete(form_filename(Dir, filenum_to_name(File))),
21392138
true = ets:delete(FileSummaryEts, File),
21402139
rabbit_log:debug("Deleted empty file number ~tp; reclaimed ~tp bytes", [File, FileSize]),

0 commit comments

Comments
 (0)