diff options
author | Matthew Sackman <matthew@lshift.net> | 2009-12-11 16:55:19 +0000 |
---|---|---|
committer | Matthew Sackman <matthew@lshift.net> | 2009-12-11 16:55:19 +0000 |
commit | f6699af0f8395570bc456987266872bc20637167 (patch) | |
tree | f28d8f14b774add1a50a758e4a6234e099e2043e | |
parent | 1aa82eccc289e9a4026b5f4efb5fe37058649bc1 (diff) | |
download | rabbitmq-server-f6699af0f8395570bc456987266872bc20637167.tar.gz |
load_segments deliberately does not adjust the pubs and acks count in the segments because doing so would clobber over values carefully constructed to contain both information from the journal and from segment, which is used to detect when flushing to a segment is unnecessary because the file is "full" and so can be deleted (i.e. pubs == acks which is sum both of in segfile and journal). On startup, we were failing to set the pubs/acks counts correctly, leading to queues doing recovery correctly but then returning a length of 0.
-rw-r--r-- | src/rabbit_queue_index.erl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index 014afbc8..003e2d62 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -171,9 +171,9 @@ init(Name) -> lists:foldl( fun (Seg, {Segments2, CountAcc, DCountAcc}) -> Segment = segment_find_or_new(Seg, Dir, Segments2), - {SegEntries, _PubCount, _AckCount, Segment1} = + {SegEntries, PubCount, AckCount, Segment1} = load_segment(false, Segment), - {Segment2 = #segment { pubs = PubCount, acks = AckCount }, + {Segment2 = #segment { pubs = PubCount1, acks = AckCount1 }, DCountAcc1} = array:sparse_foldl( fun (RelSeq, {{MsgId, _IsPersistent}, Del, no_ack}, @@ -183,9 +183,11 @@ init(Name) -> rabbit_msg_store:contains(MsgId), CleanShutdown, Del, RelSeq, Segment3), {Segment4, DCountAcc2 + DCountDelta} - end, {Segment1, DCountAcc}, SegEntries), + end, {Segment1 #segment { pubs = PubCount, + acks = AckCount }, DCountAcc}, + SegEntries), {segment_store(Segment2, Segments2), - CountAcc + PubCount - AckCount, DCountAcc1} + CountAcc + PubCount1 - AckCount1, DCountAcc1} end, {Segments, 0, DCount}, AllSegs), {Count, State2 #qistate { segments = Segments1, dirty_count = DCount1 }}. |