summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2009-11-02 11:50:13 +0000
committerMatthew Sackman <matthew@lshift.net>2009-11-02 11:50:13 +0000
commit4eec29a3d5d1f1d0da31c546b060cd59d327fcc4 (patch)
tree757c4b1f63fc921cbce85a4acb4021a97ecbd453 /src
parent4a1b5e5279127cbcf75880b4ce145dd4aefae050 (diff)
downloadrabbitmq-server-git-4eec29a3d5d1f1d0da31c546b060cd59d327fcc4.tar.gz
Documentation, cosmetic and tidying up test artifacts
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_queue_index.erl56
-rw-r--r--src/rabbit_tests.erl2
2 files changed, 29 insertions, 29 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl
index acda163654..c68a3d0460 100644
--- a/src/rabbit_queue_index.erl
+++ b/src/rabbit_queue_index.erl
@@ -40,37 +40,35 @@
%%----------------------------------------------------------------------------
%% The queue disk index
%%
-%% The queue disk index operates over an ack journal, and a number of
+%% The queue disk index operates over a journal, and a number of
%% segment files. Each segment is the same size, both in max number of
%% entries, and max file size, owing to fixed sized records.
%%
-%% Publishes and delivery notes are written directly to the segment
-%% files. The segment is found by dividing the sequence id by the the
-%% max number of entries per segment. Only the relative sequence
-%% within the segment is recorded as the sequence id within a segment
-%% file (i.e. sequence id modulo max number of entries per segment).
-%% This is keeps entries as small as possible. Publishes and
-%% deliveries are only ever going to be received in contiguous
-%% ascending order.
+%% Publishes are written directly to the segment files. The segment is
+%% found by dividing the sequence id by the the max number of entries
+%% per segment. Only the relative sequence within the segment is
+%% recorded as the sequence id within a segment file (i.e. sequence id
+%% modulo max number of entries per segment). This is keeps entries
+%% as small as possible. Publishes are only ever going to be received
+%% in contiguous ascending order.
%%
-%% Acks are written to a bounded journal and are also held in memory,
-%% in a dict with the segment file as the key. Again, the records are
-%% fixed size: the entire sequence id is written and is limited to a
-%% 64-bit unsigned integer. When the journal gets too big, or
-%% flush_journal is called, the journal is (possibly incrementally)
-%% flushed out to the segment files. As acks can be received from any
-%% delivered message in any order, this journal reduces seeking, and
-%% batches writes to the segment files, keeping performance high. The
-%% flush_journal/1 function returns a boolean indicating whether there
-%% is more flushing work that can be done. This means that the process
-%% can call this whenever it has an empty mailbox, only a small amount
-%% of work is done, allowing the process to respond quickly to new
-%% messages if they arrive, or to call flush_journal/1 several times
-%% until the result indicates there is no more flushing to be done.
+%% Acks and deliveries are written to a bounded journal and are also
+%% held in memory, each in a dict with the segment as the key. Again,
+%% the records are fixed size: the entire sequence id is written and
+%% is limited to a 63-bit unsigned integer. The remaining bit
+%% indicates whether the journal entry is for a delivery or an
+%% ack. When the journal gets too big, or flush_journal is called, the
+%% journal is (possibly incrementally) flushed out to the segment
+%% files. As acks and delivery notes can be received in any order
+%% (this is not obvious for deliveries, but consider what happens when
+%% eg msgs are *re*queued - you'll publish and then mark the msgs
+%% delivered immediately, which may be out of order), this journal
+%% reduces seeking, and batches writes to the segment files, keeping
+%% performance high.
%%
-%% On startup, the ack journal is read along with all the segment
-%% files, and the ack journal is fully flushed out to the segment
-%% files. Care is taken to ensure that no message can be ack'd twice.
+%% On startup, the journal is read along with all the segment files,
+%% and the journal is fully flushed out to the segment files. Care is
+%% taken to ensure that no message can be delivered or ack'd twice.
%%
%%----------------------------------------------------------------------------
@@ -203,9 +201,9 @@ write_delivered(SeqId, State = #qistate { journal_del_dict = JDelDict }) ->
maybe_full_flush(State1 #qistate { journal_del_dict = JDelDict1 }).
write_acks(SeqIds, State = #qistate { journal_ack_dict = JAckDict }) ->
- {JAckDict1, State1} = write_to_journal([<<?ACK_BIT:1, SeqId:?SEQ_BITS>> ||
- SeqId <- SeqIds],
- SeqIds, JAckDict, State),
+ {JAckDict1, State1} =
+ write_to_journal([<<?ACK_BIT:1, SeqId:?SEQ_BITS>> || SeqId <- SeqIds],
+ SeqIds, JAckDict, State),
maybe_full_flush(State1 #qistate { journal_ack_dict = JAckDict1 }).
sync_seq_ids(SeqIds, SyncAckJournal, State) ->
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index e3f8ddacdf..c84de421dd 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1107,4 +1107,6 @@ test_queue_index() ->
end, {true, Qi25}),
_Qi27 = rabbit_queue_index:terminate_and_erase(Qi26),
ok = stop_msg_store(),
+ ok = rabbit_queue_index:start_msg_store([]),
+ ok = stop_msg_store(),
passed.