Skip to content

Commit

Permalink
Issue #8005 was fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Mar 15, 2018
1 parent 057714d commit f9f9f97
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,30 @@ public List<String> backup(OutputStream out, Map<String, Object> options, final
} catch (Exception e) {
OLogManager.instance().error(this, "Error on callback invocation during backup", e);
}
OLogSequenceNumber freezeLSN = null;
if (writeAheadLog != null) {
freezeLSN = writeAheadLog.begin();
writeAheadLog.addCutTillLimit(freezeLSN);
}

final OutputStream bo = bufferSize > 0 ? new BufferedOutputStream(out, bufferSize) : out;
try {
return OZIPCompressionUtil
.compressDirectory(getStoragePath().toString(), bo, new String[] { ".fl", O2QCache.CACHE_STATISTIC_FILE_EXTENSION },
iOutput, compressionLevel);
final OutputStream bo = bufferSize > 0 ? new BufferedOutputStream(out, bufferSize) : out;
try {
return OZIPCompressionUtil
.compressDirectory(getStoragePath().toString(), bo, new String[] { ".fl", O2QCache.CACHE_STATISTIC_FILE_EXTENSION },
iOutput, compressionLevel);
} finally {
if (bufferSize > 0) {
bo.flush();
bo.close();
}
}
} finally {
if (bufferSize > 0) {
bo.flush();
bo.close();
if (freezeLSN != null) {
writeAheadLog.removeCutTillLimit(freezeLSN);
}
}

} finally {
release();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,21 +981,13 @@ public void addCutTillLimit(OLogSequenceNumber lsn) {
if (lsn == null)
throw new NullPointerException();

while (true) {
final Integer oldCounter = cutTillLimits.get(lsn);

final Integer newCounter;
syncObject.lock();
try {

if (oldCounter == null) {
if (cutTillLimits.putIfAbsent(lsn, 1) == null)
break;
} else {
newCounter = oldCounter + 1;
cutTillLimits.merge(lsn, 1, (a, b) -> a + b);

if (cutTillLimits.replace(lsn, oldCounter, newCounter)) {
break;
}
}
} finally {
syncObject.unlock();
}
}

Expand All @@ -1004,23 +996,23 @@ public void removeCutTillLimit(OLogSequenceNumber lsn) {
if (lsn == null)
throw new NullPointerException();

while (true) {
syncObject.lock();
try {
final Integer oldCounter = cutTillLimits.get(lsn);

if (oldCounter == null)
throw new IllegalArgumentException(String.format("Limit %s is going to be removed but it was not added", lsn));

final Integer newCounter = oldCounter - 1;
if (cutTillLimits.replace(lsn, oldCounter, newCounter)) {
if (newCounter == 0) {
cutTillLimits.remove(lsn, newCounter);
}

break;
if (newCounter == 0) {
cutTillLimits.remove(lsn);
} else {
cutTillLimits.put(lsn, newCounter);
}
} finally {
syncObject.unlock();
}
}

private OLogSegment removeHeadSegmentFromList() {
if (logSegments.size() < 2)
return null;
Expand Down

0 comments on commit f9f9f97

Please sign in to comment.