summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2010-09-09 07:13:01 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2010-09-09 07:13:01 +0100
commitfaa904d064f9f65ae21dd4a5c366b08eb9ab3d71 (patch)
treed043a432338bb2181b82475e152a036e1f4e6dc6
parent51575c57bee967400a061676b49e6aee6841c386 (diff)
downloadrabbitmq-server-git-faa904d064f9f65ae21dd4a5c366b08eb9ab3d71.tar.gz
tweak
-rw-r--r--src/rabbit_msg_store.erl49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl
index b01c3b1a4a..bfec82c5e3 100644
--- a/src/rabbit_msg_store.erl
+++ b/src/rabbit_msg_store.erl
@@ -912,36 +912,35 @@ remove_message(Guid, State = #msstate { sum_valid_data = SumValid,
file_summary_ets = FileSummaryEts,
dedup_cache_ets = DedupCacheEts }) ->
#msg_location { ref_count = RefCount, file = File,
- total_size = TotalSize } = index_lookup(Guid, State),
+ total_size = TotalSize } =
+ index_lookup_positive_refcount(Guid, State),
%% only update field, otherwise bad interaction with concurrent GC
Dec = fun () -> index_update_fields(
Guid, {#msg_location.ref_count, RefCount - 1}, State)
end,
case RefCount of
- 1 ->
- %% don't remove from CUR_FILE_CACHE_ETS_NAME here because
- %% there may be further writes in the mailbox for the same
- %% msg.
- ok = remove_cache_entry(DedupCacheEts, Guid),
- [#file_summary { valid_total_size = ValidTotalSize,
- locked = Locked }] =
- ets:lookup(FileSummaryEts, File),
- case Locked of
- true -> add_to_pending_gc_completion({remove, Guid}, State);
- false -> ok = Dec(),
- true = ets:update_element(
- FileSummaryEts, File,
- [{#file_summary.valid_total_size,
- ValidTotalSize - TotalSize}]),
- delete_file_if_empty(
- File,
- State #msstate {
- sum_valid_data = SumValid - TotalSize })
- end;
- _ when 1 < RefCount ->
- ok = decrement_cache(DedupCacheEts, Guid),
- ok = Dec(),
- State
+ %% don't remove from CUR_FILE_CACHE_ETS_NAME here because
+ %% there may be further writes in the mailbox for the same
+ %% msg.
+ 1 -> ok = remove_cache_entry(DedupCacheEts, Guid),
+ [#file_summary { valid_total_size = ValidTotalSize,
+ locked = Locked }] =
+ ets:lookup(FileSummaryEts, File),
+ case Locked of
+ true -> add_to_pending_gc_completion({remove, Guid}, State);
+ false -> ok = Dec(),
+ true = ets:update_element(
+ FileSummaryEts, File,
+ [{#file_summary.valid_total_size,
+ ValidTotalSize - TotalSize}]),
+ delete_file_if_empty(
+ File,
+ State #msstate {
+ sum_valid_data = SumValid - TotalSize })
+ end;
+ _ -> ok = decrement_cache(DedupCacheEts, Guid),
+ ok = Dec(),
+ State
end.
add_to_pending_gc_completion(