summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2009-04-13 00:49:18 +0100
committerMatthew Sackman <matthew@lshift.net>2009-04-13 00:49:18 +0100
commit7f5a97f78523cdf92016059efb227ff8ad902fa6 (patch)
treee157ae96e96d7600b6cc3ff78bb5e167e5ae06dd
parent6c07f9ea03541625f9113691a086165b4f44ca42 (diff)
downloadrabbitmq-server-git-7f5a97f78523cdf92016059efb227ff8ad902fa6.tar.gz
Fix for that bug. Basically, mnesia wasn't being deleted correctly, which meant on the subsequent startup, it would report messages which we couldn't find anywhere, as they'd been deleted from disk.
-rw-r--r--Makefile4
-rw-r--r--src/rabbit_disk_queue.erl44
2 files changed, 25 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 8744f637f9..b7464244c2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
RABBITMQ_NODENAME=rabbit
RABBITMQ_SERVER_START_ARGS=
-RABBITMQ_MNESIA_DIR=/data/tmp/rabbitmq-$(RABBITMQ_NODENAME)-mnesia
-RABBITMQ_LOG_BASE=/data/tmp
+RABBITMQ_MNESIA_DIR=/tmp/rabbitmq-$(RABBITMQ_NODENAME)-mnesia
+RABBITMQ_LOG_BASE=/tmp
SOURCE_DIR=src
EBIN_DIR=ebin
diff --git a/src/rabbit_disk_queue.erl b/src/rabbit_disk_queue.erl
index 3527fd2aeb..e2da2ce10f 100644
--- a/src/rabbit_disk_queue.erl
+++ b/src/rabbit_disk_queue.erl
@@ -240,27 +240,29 @@ remove_messages(Q, MsgIds, MnesiaDelete, State = # dqstate { msg_location = MsgL
= lists:foldl(fun (MsgId, Files2) ->
[{MsgId, RefCount, File, Offset, TotalSize}]
= ets:lookup(MsgLocation, MsgId),
- if 1 =:= RefCount ->
- true = ets:delete(MsgLocation, MsgId),
- [{File, ValidTotalSize, ContiguousTop, Left, Right}]
- = ets:lookup(FileSummary, File),
- true = ets:delete(FileDetail, {File, Offset}),
- ContiguousTop1 = lists:min([ContiguousTop, Offset]),
- true = ets:insert(FileSummary,
- {File, (ValidTotalSize - TotalSize - ?FILE_PACKING_ADJUSTMENT),
- ContiguousTop1, Left, Right}),
- if MnesiaDelete ->
- ok = mnesia:dirty_delete(rabbit_disk_queue, {MsgId, Q});
- true ->
- ok
- end,
- if CurName =:= File -> Files2;
- true -> sets:add_element(File, Files2)
- end;
- 1 < RefCount ->
- ets:insert(MsgLocation, {MsgId, RefCount - 1, File, Offset, TotalSize}),
- Files2
- end
+ Files3 =
+ if 1 =:= RefCount ->
+ true = ets:delete(MsgLocation, MsgId),
+ [{File, ValidTotalSize, ContiguousTop, Left, Right}]
+ = ets:lookup(FileSummary, File),
+ true = ets:delete(FileDetail, {File, Offset}),
+ ContiguousTop1 = lists:min([ContiguousTop, Offset]),
+ true = ets:insert(FileSummary,
+ {File, (ValidTotalSize - TotalSize - ?FILE_PACKING_ADJUSTMENT),
+ ContiguousTop1, Left, Right}),
+ if CurName =:= File -> Files2;
+ true -> sets:add_element(File, Files2)
+ end;
+ 1 < RefCount ->
+ ets:insert(MsgLocation, {MsgId, RefCount - 1, File, Offset, TotalSize}),
+ Files2
+ end,
+ if MnesiaDelete ->
+ ok = mnesia:dirty_delete(rabbit_disk_queue, {MsgId, Q});
+ true ->
+ ok
+ end,
+ Files3
end, sets:new(), MsgIds),
State2 = compact(Files, State),
{ok, State2}.