Search in sources :

Example 6 with CheckpointFile

use of org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile in project neo4j by neo4j.

the class CorruptedLogsTruncator method backupCorruptedContent.

private void backupCorruptedContent(long recoveredTransactionLogVersion, long recoveredTransactionOffset, Optional<CheckpointInfo> corruptCheckpoint) throws IOException {
    Path corruptedLogArchive = getArchiveFile(recoveredTransactionLogVersion, recoveredTransactionOffset);
    try (ZipOutputStream recoveryContent = new ZipOutputStream(fs.openAsOutputStream(corruptedLogArchive, false));
        var bufferScope = new HeapScopedBuffer(1, MebiByte, memoryTracker)) {
        LogFile transactionLogFile = logFiles.getLogFile();
        copyLogsContent(recoveredTransactionLogVersion, recoveredTransactionOffset, transactionLogFile.getHighestLogVersion(), recoveryContent, bufferScope, transactionLogFile::getLogFileForVersion);
        if (corruptCheckpoint.isPresent()) {
            LogPosition checkpointPosition = corruptCheckpoint.get().getCheckpointEntryPosition();
            CheckpointFile checkpointFile = logFiles.getCheckpointFile();
            copyLogsContent(checkpointPosition.getLogVersion(), checkpointPosition.getByteOffset(), checkpointFile.getCurrentDetachedLogVersion(), recoveryContent, bufferScope, checkpointFile::getDetachedCheckpointFileForVersion);
        }
    }
}
Also used : Path(java.nio.file.Path) HeapScopedBuffer(org.neo4j.io.memory.HeapScopedBuffer) LogFile(org.neo4j.kernel.impl.transaction.log.files.LogFile) ZipOutputStream(java.util.zip.ZipOutputStream) CheckpointFile(org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition)

Example 7 with CheckpointFile

use of org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile in project neo4j by neo4j.

the class TransactionRangeDiagnosticsTest method logs.

private static LogFiles logs(ThrowingConsumer<LogFile, IOException> transactionLogs, ThrowingConsumer<CheckpointFile, IOException> checkpointLogs) throws IOException {
    LogFiles files = mock(TransactionLogFiles.class);
    when(files.logFilesDirectory()).thenReturn(Path.of("."));
    LogFile transactionFiles = mock(LogFile.class);
    when(files.getLogFile()).thenReturn(transactionFiles);
    transactionLogs.accept(transactionFiles);
    CheckpointFile checkpointFiles = mock(CheckpointFile.class);
    when(files.getCheckpointFile()).thenReturn(checkpointFiles);
    checkpointLogs.accept(checkpointFiles);
    return files;
}
Also used : LogFile(org.neo4j.kernel.impl.transaction.log.files.LogFile) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) TransactionLogFiles(org.neo4j.kernel.impl.transaction.log.files.TransactionLogFiles) CheckpointFile(org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile)

Example 8 with CheckpointFile

use of org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile in project neo4j by neo4j.

the class DetachedCheckpointAppenderTest method appendedCheckpointsCanBeLookedUpFromCheckpointFile.

@Test
void appendedCheckpointsCanBeLookedUpFromCheckpointFile() throws IOException {
    CheckpointFile checkpointFile = logFiles.getCheckpointFile();
    var logPosition1 = new LogPosition(0, 10);
    var logPosition2 = new LogPosition(0, 20);
    var logPosition3 = new LogPosition(0, 30);
    assertThat(checkpointFile.reachableCheckpoints()).hasSize(0);
    checkpointAppender.checkPoint(LogCheckPointEvent.NULL, logPosition1, Instant.now(), "first");
    checkpointAppender.checkPoint(LogCheckPointEvent.NULL, logPosition2, Instant.now(), "second");
    checkpointAppender.checkPoint(LogCheckPointEvent.NULL, logPosition3, Instant.now(), "third");
    var checkpoints = checkpointFile.reachableCheckpoints();
    assertThat(checkpoints).hasSize(3);
    assertThat(checkpoints.get(0)).hasFieldOrPropertyWithValue("transactionLogPosition", logPosition1);
    assertThat(checkpoints.get(1)).hasFieldOrPropertyWithValue("transactionLogPosition", logPosition2);
    assertThat(checkpoints.get(2)).hasFieldOrPropertyWithValue("transactionLogPosition", logPosition3);
}
Also used : CheckpointFile(org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.jupiter.api.Test)

Aggregations

CheckpointFile (org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile)8 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)6 Test (org.junit.jupiter.api.Test)4 LogFile (org.neo4j.kernel.impl.transaction.log.files.LogFile)4 Path (java.nio.file.Path)3 File (java.io.File)1 ZipFile (java.util.zip.ZipFile)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)1 StoreChannel (org.neo4j.io.fs.StoreChannel)1 HeapScopedBuffer (org.neo4j.io.memory.HeapScopedBuffer)1 PhysicalLogVersionedStoreChannel (org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel)1 DetachedCheckpointAppender (org.neo4j.kernel.impl.transaction.log.checkpoint.DetachedCheckpointAppender)1 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)1 TransactionLogFiles (org.neo4j.kernel.impl.transaction.log.files.TransactionLogFiles)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)1 StorageEngine (org.neo4j.storageengine.api.StorageEngine)1