use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class StoreUpgraderTest method removeCheckPointFromTxLog.
public static void removeCheckPointFromTxLog(FileSystemAbstraction fileSystem, Path databaseDirectory) throws IOException {
LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseDirectory, fileSystem).withCommandReaderFactory(RecordStorageCommandReaderFactory.INSTANCE).build();
LogTailInformation logTailInformation = logFiles.getTailInformation();
if (logTailInformation.commitsAfterLastCheckpoint()) {
// done already
return;
}
// let's assume there is at least a checkpoint
assertNotNull(logTailInformation.lastCheckPoint);
LogPosition logPosition = logTailInformation.lastCheckPoint.getTransactionLogPosition();
Path logFile = logFiles.getLogFile().getLogFileForVersion(logPosition.getLogVersion());
long byteOffset = logPosition.getByteOffset();
fileSystem.truncate(logFile, byteOffset);
}
use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class LogsUpgrader method assertCleanlyShutDown.
public void assertCleanlyShutDown(DatabaseLayout layout) {
Throwable suppressibleException = null;
try {
// we should not use provided database layout here since transaction log location is different compare to previous versions
// and that's why we need to use custom transaction logs locator and database layout
DatabaseLayout oldDatabaseLayout = buildLegacyLogsLayout(layout);
LogFiles logFiles = buildLogFiles(oldDatabaseLayout);
LogTailInformation tail = logFiles.getTailInformation();
if (!tail.isRecoveryRequired()) {
// All good
return;
}
if (tail.logsMissing()) {
// There are no log files in the legacy logs location.
// Either log files are missing entirely, or they are already in their correct place.
logFiles = buildLogFiles(layout);
tail = logFiles.getTailInformation();
if (!tail.isRecoveryRequired()) {
// Log file is already in its new location, and looks good.
return;
}
if (tail.logsMissing() && !config.get(fail_on_missing_files)) {
// We don't have any log files, but we were told to ignore this.
return;
}
}
} catch (Throwable throwable) {
// ignore exception and throw db not cleanly shutdown
suppressibleException = throwable;
}
StoreUpgrader.DatabaseNotCleanlyShutDownException exception = new StoreUpgrader.DatabaseNotCleanlyShutDownException();
if (suppressibleException != null) {
exception.addSuppressed(suppressibleException);
}
throw exception;
}
use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class AbstractLogTailScannerTest method twoLogFilesSecondIsCorruptedBeforeCommit.
@ParameterizedTest
@MethodSource("params")
void twoLogFilesSecondIsCorruptedBeforeCommit(int startLogVersion, int endLogVersion) throws IOException {
setupLogFiles(endLogVersion, logFile(checkPoint()), logFile(start(), commit(2)));
Path highestLogFile = logFiles.getLogFile().getHighestLogFile();
fs.truncate(highestLogFile, fs.getFileSize(highestLogFile) - 3);
// when
LogTailInformation logTailInformation = logFiles.getTailInformation();
// then
assertLatestCheckPoint(true, true, NO_TRANSACTION_ID, false, logTailInformation);
}
use of org.neo4j.kernel.impl.transaction.log.files.LogTailInformation in project neo4j by neo4j.
the class AbstractLogTailScannerTest method twoLogFilesNoCheckPoints.
@ParameterizedTest
@MethodSource("params")
void twoLogFilesNoCheckPoints(int startLogVersion, int endLogVersion) {
// given
setupLogFiles(endLogVersion, logFile(), logFile());
// when
LogTailInformation logTailInformation = logFiles.getTailInformation();
// then
assertLatestCheckPoint(false, 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 latestLogFileContainingMultipleCheckPointsOneStartAfterBoth.
@ParameterizedTest
@MethodSource("params")
void latestLogFileContainingMultipleCheckPointsOneStartAfterBoth(int startLogVersion, int endLogVersion) {
// given
long txId = 11;
setupLogFiles(endLogVersion, logFile(checkPoint(), checkPoint(), start(), commit(txId)));
// when
LogTailInformation logTailInformation = logFiles.getTailInformation();
// then
assertLatestCheckPoint(true, true, txId, false, logTailInformation);
}
Aggregations