summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2010-02-11 11:19:34 +0000
committerMatthew Sackman <matthew@lshift.net>2010-02-11 11:19:34 +0000
commit170f35b1e9ffc8abcbf64a36067502550d30e695 (patch)
tree5fbe1cff51dddf4e120a92cde1ef1bb2a0e51a59
parent7b42cc024a23c2570a3548ac00006dafa0a74df6 (diff)
downloadrabbitmq-server-git-170f35b1e9ffc8abcbf64a36067502550d30e695.tar.gz
Fix potential leak in cur file cache if the msg is both already known and in a different file - eg same msg gets added to 2 queues, one very long, the other very short. Then memory becomes tight. By the time the short file pushes msg to disk, cur file may well have rolled over
-rw-r--r--src/rabbit_msg_store.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl
index 2a4eadc91f..2db3c34e9b 100644
--- a/src/rabbit_msg_store.erl
+++ b/src/rabbit_msg_store.erl
@@ -531,12 +531,16 @@ handle_cast({write, MsgId, Msg},
{ sum_valid_data = SumValid + TotalSize,
sum_file_size = SumFileSize + TotalSize }
)));
- #msg_location { ref_count = RefCount } ->
+ #msg_location { ref_count = RefCount, file = File } ->
%% We already know about it, just update counter. Only
%% update field otherwise bad interaction with concurrent GC
ok = index_update_fields(MsgId,
{#msg_location.ref_count, RefCount + 1},
State),
+ true = case File == CurFile of
+ true -> true;
+ false -> ets:delete(?CUR_FILE_CACHE_ETS_NAME, MsgId)
+ end,
noreply(State)
end;