summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-08-14 20:12:52 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-08-14 20:12:52 +0100
commit70005c42e1c5c40df7f75532392d39cd540b12e9 (patch)
tree0cca9dbec18fb316ee79a2d580426cafff2ca2da
parent85a9de64b873e6a9d7df2047fbc0ce3143309485 (diff)
downloadrabbitmq-server-70005c42e1c5c40df7f75532392d39cd540b12e9.tar.gz
A msg can appear > once in the same file because of multiple queues receiving the same msg. When we iterate through the msgs we find in the file, we must check that the msg corresponds to the msg in the index, by matching not just with guid but also with offset. Also just for fun, assert the total_size matches. Also, fixed a mistake in file_handle_cache where the dirty flag on the destination of copy wasn't being set.
-rw-r--r--src/file_handle_cache.erl3
-rw-r--r--src/rabbit_msg_store.erl5
2 files changed, 5 insertions, 3 deletions
diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl
index 5b348580..8db5a794 100644
--- a/src/file_handle_cache.erl
+++ b/src/file_handle_cache.erl
@@ -382,7 +382,8 @@ copy(Src, Dest, Count) ->
{ok, Count1} = Result1 ->
{Result1,
[SHandle #handle { offset = SOffset + Count1 },
- DHandle #handle { offset = DOffset + Count1 }]};
+ DHandle #handle { offset = DOffset + Count1,
+ is_dirty = true }]};
Error ->
{Error, [SHandle, DHandle]}
end;
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl
index c7ebfd97..60fcd258 100644
--- a/src/rabbit_msg_store.erl
+++ b/src/rabbit_msg_store.erl
@@ -1671,9 +1671,10 @@ find_unremoved_messages_in_file(File,
{ok, Messages, _FileSize} =
scan_file_for_valid_messages(Dir, filenum_to_name(File)),
%% foldl will reverse so will end up with msgs in ascending offset order
- lists:foldl(fun ({Guid, TotalSize, _Offset}, Acc = {List, Size}) ->
+ lists:foldl(fun ({Guid, TotalSize, Offset}, Acc = {List, Size}) ->
case Index:lookup(Guid, IndexState) of
- #msg_location { file = File } = Entry ->
+ #msg_location { file = File, total_size = TotalSize,
+ offset = Offset } = Entry ->
{[ Entry | List ], TotalSize + Size};
_ ->
Acc