LSN of latest applied record returned during restore.
@@ -6059,7 +6059,8 @@ public abstract class OAbstractPaginatedStorage extends OStorageAbstract
}
}
- protected void restoreFrom(OWriteAheadLog writeAheadLog, OLogSequenceNumber lsn)
+ @SuppressWarnings("UnusedReturnValue")
+ protected OLogSequenceNumber restoreFrom(OWriteAheadLog writeAheadLog, OLogSequenceNumber lsn)
throws IOException {
final OModifiableBoolean atLeastOnePageUpdate = new OModifiableBoolean();
@@ -6071,6 +6072,7 @@ public abstract class OAbstractPaginatedStorage extends OStorageAbstract
final Map<Long, byte[]> operationMetadata = new LinkedHashMap<>(1024);
long lastReportTime = 0;
+ OLogSequenceNumber lastUpdatedLSN = null;
try {
List<WriteableWALRecord> records = writeAheadLog.read(lsn, 1_000);
@@ -6087,7 +6089,9 @@ public abstract class OAbstractPaginatedStorage extends OStorageAbstract
if (atomicUnit != null) {
atomicUnit.add(walRecord);
if (!restoreAtomicUnit(atomicUnit, atLeastOnePageUpdate)) {
- return;
+ return lastUpdatedLSN;
+ } else {
+ lastUpdatedLSN = walRecord.getLsn();
}
}
byte[] metadata = operationMetadata.remove(atomicUnitEndRecord.getOperationUnitId());
@@ -6138,6 +6142,7 @@ public abstract class OAbstractPaginatedStorage extends OStorageAbstract
} else if (walRecord instanceof MetaDataRecord) {
final MetaDataRecord metaDataRecord = (MetaDataRecord) walRecord;
this.lastMetadata = metaDataRecord.getMetadata();
+ lastUpdatedLSN = walRecord.getLsn();
} else {
OLogManager.instance()
.warnNoDb(this, "Record %s will be skipped during data restore", walRecord);
@@ -6174,6 +6179,8 @@ public abstract class OAbstractPaginatedStorage extends OStorageAbstract
"Data restore was paused because of exception. The rest of changes will be rolled back.",
e);
}
+
+ return lastUpdatedLSN;
}
protected final boolean restoreAtomicUnit(
