Permalink
Browse files

WAL size calculation was changed.

  • Loading branch information...
1 parent 4ff011c commit 6c1e27adc4e77aa772b4d7aba22d8de9a7652e15 @laa laa committed Jul 15, 2014
@@ -617,6 +617,8 @@ public boolean accept(File dir, String name) {
flushedLsn = null;
} else {
+ logSize = 0;
+
for (File walFile : walFiles) {
LogSegment logSegment = new LogSegment(walFile, maxPagesCacheSize);
logSegment.init();
@@ -786,14 +788,15 @@ public OLogSequenceNumber log(OWALRecord record) throws IOException {
if (logSize >= maxLogSize) {
final LogSegment first = removeHeadSegmentFromList();
- if (first != null) {
- first.stopFlush(false);
+ if (first != null) {
+ first.stopFlush(false);
+
+ first.delete(false);
- logSize -= first.filledUpTo();
+ recalculateLogSize();
- first.delete(false);
- fixMasterRecords();
- }
+ fixMasterRecords();
+ }
}
if (last.filledUpTo() >= maxSegmentSize) {
@@ -810,6 +813,13 @@ public OLogSequenceNumber log(OWALRecord record) throws IOException {
}
}
+ private void recalculateLogSize() throws IOException {
+ logSize = 0;
+
+ for (LogSegment segment : logSegments)
+ logSize += segment.filledUpTo();
+ }
+
public long size() {
synchronized (syncObject) {
return logSize;
@@ -827,6 +837,8 @@ public void truncate() throws IOException {
logSegment.delete(false);
iterator.remove();
}
+
+ recalculateLogSize();
}
}
@@ -977,6 +989,8 @@ public void cutTill(OLogSequenceNumber lsn) throws IOException {
if (logSegment != null)
logSegment.delete(false);
}
+
+ recalculateLogSize();
}
}

0 comments on commit 6c1e27a

Please sign in to comment.