diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-17 18:55:44 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-17 18:55:44 +0100 |
| commit | f3114630d7c5eac34e80da0fc03469698eeab3bd (patch) | |
| tree | 3921a8740fab52888d34f8a96ffb8a6d1c725f79 /src | |
| parent | 0bda163a7f6eec6f767ce9212be8889b4e61212e (diff) | |
| download | rabbitmq-server-git-f3114630d7c5eac34e80da0fc03469698eeab3bd.tar.gz | |
treat the dedup cache the same way as the index - permit 0 ref_counts and prune on file roll
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_msg_store.erl | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index 4ca91aa1b5..4104130d9a 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -939,7 +939,7 @@ remove_message(Guid, State = #msstate { sum_valid_data = SumValid, %% 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), + ok = decrement_cache(DedupCacheEts, Guid), [#file_summary { valid_total_size = ValidTotalSize, contiguous_top = ContiguousTop, locked = Locked }] = @@ -1104,10 +1104,6 @@ update_msg_cache(CacheEts, Guid, Msg) -> fun () -> update_msg_cache(CacheEts, Guid, Msg) end) end. -remove_cache_entry(DedupCacheEts, Guid) -> - true = ets:delete(DedupCacheEts, Guid), - ok. - fetch_and_increment_cache(DedupCacheEts, Guid) -> case ets:lookup(DedupCacheEts, Guid) of [] -> @@ -1123,8 +1119,8 @@ fetch_and_increment_cache(DedupCacheEts, Guid) -> decrement_cache(DedupCacheEts, Guid) -> true = safe_ets_update_counter( DedupCacheEts, Guid, {3, -1}, - fun (N) when N =< 0 -> true = ets:delete(DedupCacheEts, Guid); - (_N) -> true + fun (N) when N < 0 -> true = ets:delete(DedupCacheEts, Guid); + (_N) -> true end, %% Guid is not in there because although it's been %% delivered, it's never actually been read (think: @@ -1425,6 +1421,7 @@ maybe_roll_to_new_file( current_file = CurFile, file_summary_ets = FileSummaryEts, cur_file_cache_ets = CurFileCacheEts, + dedup_cache_ets = DedupCacheEts, file_size_limit = FileSizeLimit }) when Offset >= FileSizeLimit -> State1 = internal_sync(State), @@ -1443,6 +1440,7 @@ maybe_roll_to_new_file( true = ets:update_element(FileSummaryEts, CurFile, {#file_summary.right, NextFile}), true = ets:match_delete(CurFileCacheEts, {'_', '_', 0}), + true = ets:match_delete(DedupCacheEts, {'_', '_', 0}), maybe_compact(State1 #msstate { current_file_handle = NextHdl, current_file = NextFile }); maybe_roll_to_new_file(_, State) -> |
