Search in sources :

Example 1 with LegacyTransactionLogsLocator

use of org.neo4j.kernel.impl.storemigration.LegacyTransactionLogsLocator in project neo4j by neo4j.

the class StoreUpgraderInterruptionTestIT method setUpLabelScanStore.

@Before
public void setUpLabelScanStore() {
    jobScheduler = new ThreadPoolJobScheduler();
    neo4jLayout = Neo4jLayout.of(directory.homePath());
    workingDatabaseLayout = neo4jLayout.databaseLayout(DEFAULT_DATABASE_NAME);
    prepareDirectory = directory.directory("prepare");
    legacyTransactionLogsLocator = new LegacyTransactionLogsLocator(Config.defaults(), workingDatabaseLayout);
    pageCache = pageCacheRule.getPageCache(fs);
    baselineFormat = RecordFormatSelector.selectForVersion(version);
    successorFormat = RecordFormatSelector.findLatestFormatInFamily(baselineFormat).orElse(baselineFormat);
}
Also used : LegacyTransactionLogsLocator(org.neo4j.kernel.impl.storemigration.LegacyTransactionLogsLocator) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) Before(org.junit.Before)

Example 2 with LegacyTransactionLogsLocator

use of org.neo4j.kernel.impl.storemigration.LegacyTransactionLogsLocator in project neo4j by neo4j.

the class RecoveryIT method failToStartDatabaseWithTransactionLogsInLegacyLocation.

@Test
void failToStartDatabaseWithTransactionLogsInLegacyLocation() throws Exception {
    GraphDatabaseAPI database = createDatabase();
    generateSomeData(database);
    managementService.shutdown();
    LogFiles logFiles = buildLogFiles();
    Path[] txLogFiles = fileSystem.listFiles(logFiles.logFilesDirectory(), path -> path.getFileName().toString().startsWith(DEFAULT_NAME));
    txLogFiles = ArrayUtil.concat(txLogFiles, logFiles.getCheckpointFile().getDetachedCheckpointFiles());
    Path databasesDirectory = databaseLayout.getNeo4jLayout().databasesDirectory();
    DatabaseLayout legacyLayout = Neo4jLayout.ofFlat(databasesDirectory).databaseLayout(databaseLayout.getDatabaseName());
    LegacyTransactionLogsLocator logsLocator = new LegacyTransactionLogsLocator(Config.defaults(), legacyLayout);
    Path transactionLogsDirectory = logsLocator.getTransactionLogsDirectory();
    assertNotNull(txLogFiles);
    assertTrue(txLogFiles.length > 0);
    for (Path logFile : txLogFiles) {
        fileSystem.moveToDirectory(logFile, transactionLogsDirectory);
    }
    AssertableLogProvider logProvider = new AssertableLogProvider();
    builder.setInternalLogProvider(logProvider);
    GraphDatabaseAPI restartedDb = createDatabase();
    try {
        DatabaseStateService dbStateService = restartedDb.getDependencyResolver().resolveDependency(DatabaseStateService.class);
        var failure = dbStateService.causeOfFailure(restartedDb.databaseId());
        assertTrue(failure.isPresent());
        assertThat(failure.get()).hasRootCauseMessage("Transaction logs are missing and recovery is not possible.");
        assertThat(logProvider.serialize()).contains(txLogFiles[0].getFileName().toString());
    } finally {
        managementService.shutdown();
    }
}
Also used : Path(java.nio.file.Path) LegacyTransactionLogsLocator(org.neo4j.kernel.impl.storemigration.LegacyTransactionLogsLocator) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) DatabaseStateService(org.neo4j.dbms.DatabaseStateService) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Aggregations

LegacyTransactionLogsLocator (org.neo4j.kernel.impl.storemigration.LegacyTransactionLogsLocator)2 Path (java.nio.file.Path)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1 DatabaseStateService (org.neo4j.dbms.DatabaseStateService)1 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)1 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)1 ThreadPoolJobScheduler (org.neo4j.test.scheduler.ThreadPoolJobScheduler)1