Search in sources :

Example 26 with LogFiles

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

the class RecoveryIT method countCheckPointsInTransactionLogs.

private int countCheckPointsInTransactionLogs() throws IOException {
    LogFiles logFiles = buildLogFiles();
    var checkpoints = logFiles.getCheckpointFile().reachableCheckpoints();
    return checkpoints.size();
}
Also used : LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles)

Example 27 with LogFiles

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

the class LogPruningIT method pruningStrategyShouldBeDynamic.

@Test
void pruningStrategyShouldBeDynamic() throws IOException {
    LogFiles logFiles = LogFilesBuilder.builder(db.databaseLayout(), fs).withLogVersionRepository(new SimpleLogVersionRepository()).withLastCommittedTransactionIdSupplier(() -> 1).withCommandReaderFactory(db.getDependencyResolver().resolveDependency(StorageEngineFactory.class).commandReaderFactory()).withTransactionIdStore(new SimpleTransactionIdStore()).build();
    // Force transaction log rotation
    writeTransactionsAndRotateTwice();
    // Checkpoint to make sure strategy is evaluated
    checkPointer.forceCheckPoint(triggerInfo);
    // Make sure file is still there since we have disable pruning. 3 transaction logs and 1 separate checkpoint file.
    assertThat(countTransactionLogs(logFiles)).isEqualTo(4);
    // Change pruning to true
    config.setDynamic(keep_logical_logs, FALSE, "LogPruningIT");
    // Checkpoint to make sure strategy is evaluated
    checkPointer.forceCheckPoint(triggerInfo);
    // Make sure file is removed
    assertThat(countTransactionLogs(logFiles)).isEqualTo(3);
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Test(org.junit.jupiter.api.Test)

Example 28 with LogFiles

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

the class MissingStoreFilesRecoveryIT method failToStartOnMissingFilesAndPartialTransactionLogs.

@Test
void failToStartOnMissingFilesAndPartialTransactionLogs() throws IOException {
    LogFiles logFiles = prepareDatabaseWithTwoTxLogFiles();
    fileSystem.deleteFile(logFiles.getLogFile().getLogFileForVersion(0));
    fileSystem.deleteFile(databaseLayout.nodeStore());
    var dbStateService = getDatabaseStateService();
    var failure = dbStateService.causeOfFailure(defaultNamedDatabaseId);
    assertFalse(failure.isPresent());
    assertFalse(fileSystem.fileExists(databaseLayout.nodeStore()));
}
Also used : LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) Test(org.junit.jupiter.api.Test)

Example 29 with LogFiles

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

the class MissingStoreFilesRecoveryIT method rotateTransactionLogs.

private static LogFiles rotateTransactionLogs(GraphDatabaseAPI databaseApi) throws IOException {
    LogFiles logFiles = databaseApi.getDependencyResolver().resolveDependency(LogFiles.class);
    LogFile logFile = logFiles.getLogFile();
    logFile.rotate();
    return logFiles;
}
Also used : LogFile(org.neo4j.kernel.impl.transaction.log.files.LogFile) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles)

Example 30 with LogFiles

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

the class Runner method call.

@Override
public Long call() throws Exception {
    long lastCommittedTransactionId;
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
        Lifespan life = new Lifespan()) {
        TransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
        TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache();
        LogFiles logFiles = life.add(createLogFiles(transactionIdStore, fileSystem));
        TransactionAppender transactionAppender = life.add(createBatchingTransactionAppender(transactionIdStore, transactionMetadataCache, logFiles));
        ExecutorService executorService = Executors.newFixedThreadPool(threads);
        try {
            List<Future<?>> handlers = new ArrayList<>(threads);
            for (int i = 0; i < threads; i++) {
                TransactionRepresentationFactory factory = new TransactionRepresentationFactory();
                Worker task = new Worker(transactionAppender, factory, condition);
                handlers.add(executorService.submit(task));
            }
            // wait for all the workers to complete
            Futures.getAll(handlers);
        } finally {
            executorService.shutdown();
        }
        lastCommittedTransactionId = transactionIdStore.getLastCommittedTransactionId();
    }
    return lastCommittedTransactionId;
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) TransactionAppender(org.neo4j.kernel.impl.transaction.log.TransactionAppender) BatchingTransactionAppender(org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) ArrayList(java.util.ArrayList) TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) Lifespan(org.neo4j.kernel.lifecycle.Lifespan)

Aggregations

LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)61 Test (org.junit.jupiter.api.Test)33 LogFile (org.neo4j.kernel.impl.transaction.log.files.LogFile)21 SimpleTransactionIdStore (org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore)16 Path (java.nio.file.Path)13 IOException (java.io.IOException)10 SimpleLogVersionRepository (org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository)10 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)9 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)9 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)8 TransactionIdStore (org.neo4j.storageengine.api.TransactionIdStore)8 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)7 StoreChannel (org.neo4j.io.fs.StoreChannel)7 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)7 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 LogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader)4 UncheckedIOException (java.io.UncheckedIOException)3