use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class AbstractLogTailScannerTest method olderLogFileContainingACheckPointAndNewerFileIsEmpty.
@ParameterizedTest
@MethodSource("params")
void olderLogFileContainingACheckPointAndNewerFileIsEmpty(int startLogVersion, int endLogVersion) {
// given
StartEntry start = start();
setupLogFiles(endLogVersion, logFile(start, commit(1), checkPoint()), logFile());
// when
LogTailInformation logTailInformation = logFiles.getTailInformation();
// then
assertLatestCheckPoint(true, false, NO_TRANSACTION_ID, false, logTailInformation);
}
use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class AbstractLogTailScannerTest method twoLogFilesNoCheckPointsOneStart.
@ParameterizedTest
@MethodSource("params")
void twoLogFilesNoCheckPointsOneStart(int startLogVersion, int endLogVersion) {
// given
long txId = 21;
setupLogFiles(endLogVersion, logFile(), logFile(start(), commit(txId)));
// when
LogTailInformation logTailInformation = logFiles.getTailInformation();
// then
assertLatestCheckPoint(false, true, txId, false, logTailInformation);
}
use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class RecoveryStartInformationProviderTest method detectMissingTransactionLogsInformation.
@Test
void detectMissingTransactionLogsInformation() {
when(logFiles.getTailInformation()).thenReturn(new LogTailInformation(false, -1, true, -1, LATEST.version()));
RecoveryStartInformation recoveryStartInformation = new RecoveryStartInformationProvider(logFiles, monitor).get();
assertSame(MISSING_LOGS, recoveryStartInformation);
}
use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class RecoveryStartInformationProviderTest method shouldRecoverFromStartOfLogZeroIfThereAreNoCheckPointAndOldestLogIsVersionZero.
@Test
void shouldRecoverFromStartOfLogZeroIfThereAreNoCheckPointAndOldestLogIsVersionZero() {
// given
when(logFiles.getTailInformation()).thenReturn(new LogTailInformation(true, 10L, false, currentLogVersion, LATEST.version()));
// when
RecoveryStartInformation recoveryStartInformation = new RecoveryStartInformationProvider(logFiles, monitor).get();
// then
verify(monitor).noCheckPointFound();
assertEquals(new LogPosition(0, CURRENT_FORMAT_LOG_HEADER_SIZE), recoveryStartInformation.getTransactionLogPosition());
assertEquals(new LogPosition(0, CURRENT_FORMAT_LOG_HEADER_SIZE), recoveryStartInformation.getCheckpointPosition());
assertEquals(10L, recoveryStartInformation.getFirstTxIdAfterLastCheckPoint());
assertTrue(recoveryStartInformation.isRecoveryRequired());
}
use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class RecoveryStartInformationProvider method get.
/**
* Find the log position to start recovery from
*
* @return {@link LogPosition#UNSPECIFIED} if there is no need to recover otherwise the {@link LogPosition} to
* start recovery from
* @throws IOException if log files cannot be read
*/
@Override
public RecoveryStartInformation get() {
LogTailInformation logTailInformation = logFiles.getTailInformation();
CheckpointInfo lastCheckPoint = logTailInformation.lastCheckPoint;
long txIdAfterLastCheckPoint = logTailInformation.firstTxIdAfterLastCheckPoint;
if (!logTailInformation.isRecoveryRequired()) {
monitor.noCommitsAfterLastCheckPoint(lastCheckPoint != null ? lastCheckPoint.getTransactionLogPosition() : null);
return NO_RECOVERY_REQUIRED;
}
if (logTailInformation.logsMissing()) {
return MISSING_LOGS;
}
if (logTailInformation.commitsAfterLastCheckpoint()) {
if (lastCheckPoint == null) {
long lowestLogVersion = logFiles.getLogFile().getLowestLogVersion();
if (lowestLogVersion != INITIAL_LOG_VERSION) {
throw new UnderlyingStorageException("No check point found in any log file from version " + lowestLogVersion + " to " + logTailInformation.currentLogVersion);
}
monitor.noCheckPointFound();
LogPosition position = tryExtractHeaderSize();
return createRecoveryInformation(position, new LogPosition(INITIAL_LOG_VERSION, CURRENT_FORMAT_LOG_HEADER_SIZE), txIdAfterLastCheckPoint);
}
LogPosition transactionLogPosition = lastCheckPoint.getTransactionLogPosition();
monitor.commitsAfterLastCheckPoint(transactionLogPosition, txIdAfterLastCheckPoint);
return createRecoveryInformation(transactionLogPosition, lastCheckPoint.getCheckpointEntryPosition(), txIdAfterLastCheckPoint);
} else {
throw new UnderlyingStorageException("Fail to determine recovery information Log tail info: " + logTailInformation);
}
}
Aggregations