diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-10-16 18:17:15 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-10-16 18:17:15 +0100 |
| commit | 52fa85c4018007d1944302f6f315ef5fc7f5d724 (patch) | |
| tree | 0a28c334675412217247773a9dd65a63cc60409f | |
| parent | 5e5f0bce867136740b7989540aab674d4339021f (diff) | |
| download | rabbitmq-server-git-52fa85c4018007d1944302f6f315ef5fc7f5d724.tar.gz | |
If we don't fully flush the journal when it becomes full then we are negating the point of the journal as it means we very frequently fill it and then have to empty it to one file, whereas if we fully empty it then it takes much longer to fill, and then we empty to several files
| -rw-r--r-- | src/rabbit_queue_index.erl | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index 708891d9c6..9c18b7843f 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -179,16 +179,12 @@ init(Name) -> terminate(State = #qistate { journal_handle = undefined }) -> State; terminate(State) -> - case flush_journal(State) of - {true, State1} -> - terminate(State1); - {false, State1 = #qistate { cur_seg_num = SegNum }} -> - State2 = #qistate { journal_handle = JournalHdl } = - close_file_handle_for_seg(SegNum, State1), - ok = file:sync(JournalHdl), - ok = file:close(JournalHdl), - State2 #qistate { journal_handle = undefined } - end. + State1 = #qistate { cur_seg_num = SegNum } = full_flush_journal(State), + State2 = #qistate { journal_handle = JournalHdl } = + close_file_handle_for_seg(SegNum, State1), + ok = file:sync(JournalHdl), + ok = file:close(JournalHdl), + State2 #qistate { journal_handle = undefined }. terminate_and_erase(State) -> State1 = terminate(State), @@ -226,11 +222,16 @@ write_acks(SeqIds, State = #qistate { journal_handle = JournalHdl, State1 = State #qistate { journal_ack_dict = JAckDict1, journal_ack_count = JAckCount1 }, case JAckCount1 > ?MAX_ACK_JOURNAL_ENTRY_COUNT of - true -> {_Cont, State2} = flush_journal(State1), - State2; + true -> full_flush_journal(State1); false -> State1 end. +full_flush_journal(State) -> + case flush_journal(State) of + {true, State1} -> full_flush_journal(State1); + {false, State1} -> State1 + end. + flush_journal(State = #qistate { journal_ack_count = 0 }) -> {false, State}; flush_journal(State = #qistate { journal_handle = JournalHdl, |
