Search in sources :

Example 1 with RecordStorageEngineFactory

use of org.neo4j.internal.recordstorage.RecordStorageEngineFactory in project neo4j by neo4j.

the class RecordStorageMigratorIT method shouldBeAbleToMigrateWithoutErrors.

@ParameterizedTest
@MethodSource("versions")
void shouldBeAbleToMigrateWithoutErrors(String version, LogPosition expectedLogPosition, Function<TransactionId, Boolean> txIdComparator) throws Exception {
    // GIVEN a legacy database
    Path prepare = testDirectory.directory("prepare");
    var fs = testDirectory.getFileSystem();
    MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, databaseLayout.databaseDirectory(), prepare);
    AssertableLogProvider logProvider = new AssertableLogProvider(true);
    LogService logService = new SimpleLogService(logProvider, logProvider);
    RecordStoreVersionCheck check = getVersionCheck(pageCache, databaseLayout);
    String versionToMigrateFrom = getVersionToMigrateFrom(check);
    RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, PageCacheTracer.NULL, batchImporterFactory, INSTANCE);
    // WHEN migrating
    migrator.migrate(databaseLayout, migrationLayout, progressMonitor.startSection("section"), versionToMigrateFrom, getVersionToMigrateTo(check), EMPTY);
    migrator.moveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, getVersionToMigrateTo(check));
    // THEN starting the new store should be successful
    assertThat(testDirectory.getFileSystem().fileExists(databaseLayout.relationshipGroupDegreesStore())).isTrue();
    GBPTreeRelationshipGroupDegreesStore.DegreesRebuilder noRebuildAssertion = new GBPTreeRelationshipGroupDegreesStore.DegreesRebuilder() {

        @Override
        public void rebuild(RelationshipGroupDegreesStore.Updater updater, CursorContext cursorContext, MemoryTracker memoryTracker) {
            throw new IllegalStateException("Rebuild should not be required");
        }

        @Override
        public long lastCommittedTxId() {
            try {
                return new RecordStorageEngineFactory().readOnlyTransactionIdStore(fs, databaseLayout, pageCache, NULL).getLastCommittedTransactionId();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    };
    try (GBPTreeRelationshipGroupDegreesStore groupDegreesStore = new GBPTreeRelationshipGroupDegreesStore(pageCache, databaseLayout.relationshipGroupDegreesStore(), testDirectory.getFileSystem(), immediate(), noRebuildAssertion, writable(), PageCacheTracer.NULL, GBPTreeGenericCountsStore.NO_MONITOR, databaseLayout.getDatabaseName(), counts_store_max_cached_entries.defaultValue())) {
        // The rebuild would happen here in start and will throw exception (above) if invoked
        groupDegreesStore.start(NULL, INSTANCE);
        // The store keeps track of committed transactions.
        // It is essential that it starts with the transaction
        // that is the last committed one at the upgrade time.
        assertEquals(TX_ID, groupDegreesStore.txId());
    }
    StoreFactory storeFactory = new StoreFactory(databaseLayout, CONFIG, new ScanOnOpenOverwritingIdGeneratorFactory(fs, databaseLayout.getDatabaseName()), pageCache, fs, logService.getInternalLogProvider(), PageCacheTracer.NULL, writable());
    storeFactory.openAllNeoStores().close();
    assertThat(logProvider).forLevel(ERROR).doesNotHaveAnyLogs();
}
Also used : Path(java.nio.file.Path) RecordStorageEngineFactory(org.neo4j.internal.recordstorage.RecordStorageEngineFactory) SimpleLogService(org.neo4j.logging.internal.SimpleLogService) UncheckedIOException(java.io.UncheckedIOException) CursorContext(org.neo4j.io.pagecache.context.CursorContext) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) MemoryTracker(org.neo4j.memory.MemoryTracker) GBPTreeRelationshipGroupDegreesStore(org.neo4j.internal.counts.GBPTreeRelationshipGroupDegreesStore) NullLogService(org.neo4j.logging.internal.NullLogService) SimpleLogService(org.neo4j.logging.internal.SimpleLogService) LogService(org.neo4j.logging.internal.LogService) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) ScanOnOpenOverwritingIdGeneratorFactory(org.neo4j.internal.id.ScanOnOpenOverwritingIdGeneratorFactory) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with RecordStorageEngineFactory

use of org.neo4j.internal.recordstorage.RecordStorageEngineFactory in project neo4j by neo4j.

the class StoreUpgraderInterruptionTestIT method newUpgrader.

private StoreUpgrader newUpgrader(StoreVersionCheck versionCheck, MigrationProgressMonitor progressMonitor, StoreMigrationParticipant... participants) {
    Config config = Config.defaults(allow_upgrade, true);
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependencies(new Monitors());
    RecordStorageEngineFactory storageEngineFactory = new RecordStorageEngineFactory();
    var databaseHealth = new DatabaseHealth(PanicEventGenerator.NO_OP, NullLog.getInstance());
    LogsUpgrader logsUpgrader = new LogsUpgrader(fs, storageEngineFactory, workingDatabaseLayout, pageCache, legacyTransactionLogsLocator, config, dependencies, NULL, INSTANCE, databaseHealth, false);
    StoreUpgrader upgrader = new StoreUpgrader(versionCheck, progressMonitor, config, fs, NullLogProvider.getInstance(), logsUpgrader, NULL);
    for (StoreMigrationParticipant participant : participants) {
        upgrader.addParticipant(participant);
    }
    return upgrader;
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) RecordStorageEngineFactory(org.neo4j.internal.recordstorage.RecordStorageEngineFactory) LogsUpgrader(org.neo4j.kernel.impl.storemigration.LogsUpgrader) Config(org.neo4j.configuration.Config) StoreMigrationParticipant(org.neo4j.storageengine.migration.StoreMigrationParticipant) Monitors(org.neo4j.monitoring.Monitors) Dependencies(org.neo4j.collection.Dependencies) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader)

Aggregations

RecordStorageEngineFactory (org.neo4j.internal.recordstorage.RecordStorageEngineFactory)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 Path (java.nio.file.Path)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 Dependencies (org.neo4j.collection.Dependencies)1 Config (org.neo4j.configuration.Config)1 GBPTreeRelationshipGroupDegreesStore (org.neo4j.internal.counts.GBPTreeRelationshipGroupDegreesStore)1 ScanOnOpenOverwritingIdGeneratorFactory (org.neo4j.internal.id.ScanOnOpenOverwritingIdGeneratorFactory)1 CursorContext (org.neo4j.io.pagecache.context.CursorContext)1 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)1 LogsUpgrader (org.neo4j.kernel.impl.storemigration.LogsUpgrader)1 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)1 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)1 LogService (org.neo4j.logging.internal.LogService)1 NullLogService (org.neo4j.logging.internal.NullLogService)1 SimpleLogService (org.neo4j.logging.internal.SimpleLogService)1 MemoryTracker (org.neo4j.memory.MemoryTracker)1 DatabaseHealth (org.neo4j.monitoring.DatabaseHealth)1