use of org.neo4j.kernel.impl.storemigration.RecordStorageMigrator in project neo4j by neo4j.
the class StoreUpgraderInterruptionTestIT method shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration.
@Test
public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration() throws IOException, ConsistencyCheckIncompleteException {
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, workingDatabaseLayout.databaseDirectory(), prepareDirectory);
RecordStoreVersionCheck versionCheck = new RecordStoreVersionCheck(fs, pageCache, workingDatabaseLayout, NullLogProvider.getInstance(), Config.defaults(), NULL);
MigrationProgressMonitor progressMonitor = MigrationProgressMonitor.SILENT;
LogService logService = NullLogService.getInstance();
RecordStorageMigrator failingStoreMigrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE) {
@Override
public void migrate(DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo, IndexImporterFactory indexImporterFactory) throws IOException, KernelException {
super.migrate(directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, versionToMigrateTo, indexImporterFactory);
throw new RuntimeException("This upgrade is failing");
}
};
try {
newUpgrader(versionCheck, progressMonitor, createIndexMigrator(), failingStoreMigrator).migrateIfNeeded(workingDatabaseLayout, false);
fail("Should throw exception");
} catch (RuntimeException e) {
assertEquals("This upgrade is failing", e.getMessage());
}
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, baselineFormat));
RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE);
IdGeneratorMigrator idMigrator = new IdGeneratorMigrator(fs, pageCache, CONFIG, NULL);
SchemaIndexMigrator indexMigrator = createIndexMigrator();
newUpgrader(versionCheck, progressMonitor, indexMigrator, migrator, idMigrator).migrateIfNeeded(workingDatabaseLayout, false);
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, successorFormat));
// Since consistency checker is in read only mode we need to start/stop db to generate label scan store.
startStopDatabase(neo4jLayout.homeDirectory());
assertConsistentStore(workingDatabaseLayout);
}
use of org.neo4j.kernel.impl.storemigration.RecordStorageMigrator in project neo4j by neo4j.
the class RecordStorageEngineFactory method migrationParticipants.
@Override
public List<StoreMigrationParticipant> migrationParticipants(FileSystemAbstraction fs, Config config, PageCache pageCache, JobScheduler jobScheduler, LogService logService, PageCacheTracer cacheTracer, MemoryTracker memoryTracker) {
BatchImporterFactory batchImporterFactory = BatchImporterFactory.withHighestPriority();
RecordStorageMigrator recordStorageMigrator = new RecordStorageMigrator(fs, pageCache, config, logService, jobScheduler, cacheTracer, batchImporterFactory, memoryTracker);
IdGeneratorMigrator idGeneratorMigrator = new IdGeneratorMigrator(fs, pageCache, config, cacheTracer);
return List.of(recordStorageMigrator, idGeneratorMigrator);
}
use of org.neo4j.kernel.impl.storemigration.RecordStorageMigrator in project neo4j by neo4j.
the class StoreUpgraderInterruptionTestIT method shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles.
@Test
public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles() throws IOException, ConsistencyCheckIncompleteException {
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, workingDatabaseLayout.databaseDirectory(), prepareDirectory);
RecordStoreVersionCheck versionCheck = new RecordStoreVersionCheck(fs, pageCache, workingDatabaseLayout, NullLogProvider.getInstance(), Config.defaults(), NULL);
MigrationProgressMonitor progressMonitor = MigrationProgressMonitor.SILENT;
LogService logService = NullLogService.getInstance();
RecordStorageMigrator failingStoreMigrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE) {
@Override
public void moveMigratedFiles(DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToUpgradeFrom, String versionToMigrateTo) throws IOException {
super.moveMigratedFiles(migrationLayout, directoryLayout, versionToUpgradeFrom, versionToMigrateTo);
throw new RuntimeException("This upgrade is failing");
}
};
IdGeneratorMigrator idMigrator = new IdGeneratorMigrator(fs, pageCache, CONFIG, NULL);
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, baselineFormat));
try {
newUpgrader(versionCheck, progressMonitor, createIndexMigrator(), failingStoreMigrator, idMigrator).migrateIfNeeded(workingDatabaseLayout, false);
fail("Should throw exception");
} catch (RuntimeException e) {
assertEquals("This upgrade is failing", e.getMessage());
}
RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE);
newUpgrader(versionCheck, progressMonitor, createIndexMigrator(), migrator, idMigrator).migrateIfNeeded(workingDatabaseLayout, false);
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, successorFormat));
pageCache.close();
// Since consistency checker is in read only mode we need to start/stop db to generate label scan store.
startStopDatabase(neo4jLayout.homeDirectory());
assertConsistentStore(workingDatabaseLayout);
}
use of org.neo4j.kernel.impl.storemigration.RecordStorageMigrator in project neo4j by neo4j.
the class StoreUpgraderInterruptionTestIT method tracePageCacheAccessOnIdStoreUpgrade.
@Test
public void tracePageCacheAccessOnIdStoreUpgrade() throws IOException, ConsistencyCheckIncompleteException {
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, workingDatabaseLayout.databaseDirectory(), prepareDirectory);
RecordStoreVersionCheck versionCheck = new RecordStoreVersionCheck(fs, pageCache, workingDatabaseLayout, NullLogProvider.getInstance(), Config.defaults(), NULL);
MigrationProgressMonitor progressMonitor = MigrationProgressMonitor.SILENT;
LogService logService = NullLogService.getInstance();
var idMigratorTracer = new DefaultPageCacheTracer();
var recordMigratorTracer = new DefaultPageCacheTracer();
IdGeneratorMigrator idMigrator = new IdGeneratorMigrator(fs, pageCache, CONFIG, idMigratorTracer);
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, baselineFormat));
var migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, recordMigratorTracer, batchImporterFactory, INSTANCE);
newUpgrader(versionCheck, progressMonitor, createIndexMigrator(), migrator, idMigrator).migrateIfNeeded(workingDatabaseLayout, false);
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, successorFormat));
startStopDatabase(neo4jLayout.homeDirectory());
assertConsistentStore(workingDatabaseLayout);
assertEquals(43, idMigratorTracer.faults());
assertEquals(83, idMigratorTracer.hits());
assertEquals(126, idMigratorTracer.pins());
assertEquals(126, idMigratorTracer.unpins());
assertEquals(61, recordMigratorTracer.faults());
assertEquals(228, recordMigratorTracer.hits());
assertEquals(289, recordMigratorTracer.pins());
assertEquals(289, recordMigratorTracer.unpins());
}
Aggregations