Search in sources :

Example 81 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class RecoveryIT method recoverySetsCheckpointLogVersionFieldNoCheckpointFiles.

@Test
void recoverySetsCheckpointLogVersionFieldNoCheckpointFiles() throws Exception {
    GraphDatabaseAPI db = createDatabase();
    generateSomeData(db);
    DatabaseLayout layout = db.databaseLayout();
    managementService.shutdown();
    removeFileWithCheckpoint();
    assertTrue(isRecoveryRequired(layout));
    MetaDataStore.setRecord(pageCache, layout.metadataStore(), CHECKPOINT_LOG_VERSION, -5, layout.getDatabaseName(), NULL);
    recoverDatabase();
    assertFalse(isRecoveryRequired(layout));
    assertEquals(0, MetaDataStore.getRecord(pageCache, layout.metadataStore(), CHECKPOINT_LOG_VERSION, layout.getDatabaseName(), NULL));
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Test(org.junit.jupiter.api.Test)

Example 82 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class KernelDiagnosticsTest method shouldCountFileSizeRecursively.

@Test
void shouldCountFileSizeRecursively() throws IOException {
    // file structure:
    // storeDir/indexDir/indexFile (1 kB)
    // storeDir/neostore (3 kB)
    Path storeDir = testDirectory.directory("storedir");
    DatabaseLayout layout = DatabaseLayout.ofFlat(storeDir);
    Path indexDir = directory(storeDir, "indexDir");
    file(indexDir, "indexFile", (int) kibiBytes(1));
    file(storeDir, layout.metadataStore().getFileName().toString(), (int) kibiBytes(3));
    StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
    when(storageEngineFactory.listStorageFiles(any(), any())).thenReturn(singletonList(layout.metadataStore()));
    AssertableLogProvider logProvider = new AssertableLogProvider();
    StoreFilesDiagnostics storeFiles = new StoreFilesDiagnostics(storageEngineFactory, fs, layout);
    storeFiles.dump(logProvider.getLog(getClass())::debug);
    assertThat(logProvider).containsMessages("Total size of store: 4.000KiB", "Total size of mapped files: 3.000KiB");
}
Also used : Path(java.nio.file.Path) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 83 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class AllNodesInStoreExistInLabelIndexTest method fullConsistencyCheck.

ConsistencyCheckService.Result fullConsistencyCheck() throws ConsistencyCheckIncompleteException {
    ConsistencyCheckService service = new ConsistencyCheckService();
    DatabaseLayout databaseLayout = db.databaseLayout();
    Config config = Config.defaults(logs_directory, databaseLayout.databaseDirectory());
    return service.runFullConsistencyCheck(databaseLayout, addAdditionalConfigToCC(config), NONE, log, false, ConsistencyFlags.DEFAULT);
}
Also used : Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService)

Example 84 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class IndexConsistencyIT method reportNotCleanNativeIndex.

@Test
void reportNotCleanNativeIndex() throws IOException, ConsistencyCheckIncompleteException {
    DatabaseLayout databaseLayout = db.databaseLayout();
    someData();
    checkPointer.forceCheckPoint(new SimpleTriggerInfo("forcedCheckpoint"));
    Path indexesCopy = databaseLayout.file("indexesCopy");
    Path indexSources = indexProviderMap.getDefaultProvider().directoryStructure().rootDirectory();
    copyDirectory(indexSources, indexesCopy, SOURCE_COPY_FILE_FILTER);
    try (Transaction tx = db.beginTx()) {
        createNewNode(tx, new Label[] { LABEL_ONE });
        tx.commit();
    }
    managementService.shutdown();
    copyDirectory(indexesCopy, indexSources);
    ConsistencyCheckService.Result result = fullConsistencyCheck();
    assertFalse(result.isSuccessful(), "Expected consistency check to fail");
    assertThat(readReport(result)).contains("WARN  Index was dirty on startup which means it was not shutdown correctly and need to be cleaned up with a successful recovery.");
}
Also used : Path(java.nio.file.Path) SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) Transaction(org.neo4j.graphdb.Transaction) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) Test(org.junit.jupiter.api.Test)

Example 85 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class IndexConsistencyIT method reportNotCleanNativeIndexWithCorrectData.

@Test
void reportNotCleanNativeIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException {
    DatabaseLayout databaseLayout = db.databaseLayout();
    someData();
    checkPointer.forceCheckPoint(new SimpleTriggerInfo("forcedCheckpoint"));
    Path indexesCopy = databaseLayout.file("indexesCopy");
    Path indexSources = indexProviderMap.getDefaultProvider().directoryStructure().rootDirectory();
    copyDirectory(indexSources, indexesCopy, SOURCE_COPY_FILE_FILTER);
    managementService.shutdown();
    copyDirectory(indexesCopy, indexSources);
    ConsistencyCheckService.Result result = fullConsistencyCheck();
    assertTrue(result.isSuccessful(), "Expected consistency check to fail");
    assertThat(readReport(result)).contains("WARN  Index was dirty on startup which means it was not shutdown correctly and need to be cleaned up with a successful recovery.");
}
Also used : Path(java.nio.file.Path) SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) Test(org.junit.jupiter.api.Test)

Aggregations

DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)108 Test (org.junit.jupiter.api.Test)66 Path (java.nio.file.Path)51 Config (org.neo4j.configuration.Config)35 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)24 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)19 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)17 PageCache (org.neo4j.io.pagecache.PageCache)17 IOException (java.io.IOException)16 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)16 Transaction (org.neo4j.graphdb.Transaction)13 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)10 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)9 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)9 CommandFailedException (org.neo4j.cli.CommandFailedException)8 ExecutionContext (org.neo4j.cli.ExecutionContext)8 PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)8 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)8 Closeable (java.io.Closeable)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7