diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2011-10-10 18:19:33 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2011-10-10 18:19:33 +0100 |
| commit | 2ef30dc95eaa7e04a0371fef0de8154f40a36685 (patch) | |
| tree | f2ee90f1b7692dd4e3ec0aa537d317f310c7de21 /src | |
| parent | 60a02152a77f802b08d5fc27e8c1a91b048732d7 (diff) | |
| download | rabbitmq-server-git-2ef30dc95eaa7e04a0371fef0de8154f40a36685.tar.gz | |
be more careful about deleting cur_file_cache_ets entries
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_msg_store.erl | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index c05c68e93f..edb1d8b186 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -781,12 +781,23 @@ handle_cast({write, CRef, MsgId}, end, CRef, State1) end); ignore -> - %% A remove has already been issued and eliminated the - %% write. When a msg has been removed, then it won't be - %% followed by a read, so let's remove it from the - %% cur_file_cache_ets here in order to avoid unbounded - %% cache growth when all writes are eliminated. - true = ets:match_delete(CurFileCacheEts, {MsgId, '_', 0}), + %% A 'remove' has already been issued and eliminated the + %% 'write'. If all writes get eliminated, + %% cur_file_cache_ets could grow unbounded. To prevent + %% that we delete the cache entry here, but only if the + %% message isn't in the current file. That way reads of + %% the message can continue to be done client side, from + %% either the cache or the non-current files. If the + %% message *is* in the current file then the cache entry + %% will be removed by the normal logic for that, + %% e.g. above and during file rolling. + case index_lookup(MsgId, State) of + [#msg_location { file = File }] + when File == State #msstate.current_file -> + ok; + _ -> + true = ets:match_delete(CurFileCacheEts, {MsgId, '_', 0}) + end, noreply(State) end; |
