use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method notParticipatingParticipantsAreNotPartOfMigration.
@ParameterizedTest
@MethodSource("versions")
void notParticipatingParticipantsAreNotPartOfMigration(RecordFormats formats) throws IOException {
init(formats);
StoreVersionCheck check = getVersionCheck(pageCache);
StoreUpgrader storeUpgrader = newUpgrader(check, pageCache);
assertThat(storeUpgrader.getParticipants()).hasSize(2);
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method forbidRegistrationOfParticipantsWithSameName.
@ParameterizedTest
@MethodSource("versions")
void forbidRegistrationOfParticipantsWithSameName(RecordFormats formats) throws IOException {
init(formats);
StoreVersionCheck check = getVersionCheck(pageCache);
StoreUpgrader upgrader = newUpgrader(check, allowMigrateConfig, pageCache);
upgrader.addParticipant(new EmptyNamedMigrationParticipant("foo"));
assertThrows(IllegalStateException.class, () -> upgrader.addParticipant(new EmptyNamedMigrationParticipant("foo")));
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class RecordStoreVersionCheckTest method shouldReportFileWithIncorrectVersion.
@Test
void shouldReportFileWithIncorrectVersion() throws IOException {
// given
Path neoStore = emptyFile(fileSystem);
long v1 = MetaDataStore.versionStringToLong("V1");
MetaDataStore.setRecord(pageCache, neoStore, MetaDataStore.Position.STORE_VERSION, v1, databaseLayout.getDatabaseName(), NULL);
RecordStoreVersionCheck storeVersionCheck = newStoreVersionCheck();
// when
StoreVersionCheck.Result result = storeVersionCheck.checkUpgrade("V2", NULL);
// then
assertFalse(result.outcome.isSuccessful());
assertEquals(Outcome.unexpectedStoreVersion, result.outcome);
assertEquals("V1", result.actualVersion);
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class RecordStoreVersionCheckTest method tracePageCacheAccessOnCheckUpgradable.
@Test
void tracePageCacheAccessOnCheckUpgradable() throws IOException {
Path neoStore = emptyFile(fileSystem);
String storeVersion = "V1";
long v1 = MetaDataStore.versionStringToLong(storeVersion);
MetaDataStore.setRecord(pageCache, neoStore, MetaDataStore.Position.STORE_VERSION, v1, databaseLayout.getDatabaseName(), NULL);
RecordStoreVersionCheck storeVersionCheck = newStoreVersionCheck();
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnCheckUpgradable"));
StoreVersionCheck.Result result = storeVersionCheck.checkUpgrade(storeVersion, cursorContext);
assertTrue(result.outcome.isSuccessful());
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isOne();
assertThat(cursorTracer.unpins()).isOne();
assertThat(cursorTracer.faults()).isOne();
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class DatabaseMigrator method migrate.
/**
* Performs construction of {@link StoreUpgrader} and all of the necessary participants and performs store
* migration if that is required.
*
* @param forceUpgrade Ignore the value of the {@link GraphDatabaseSettings#allow_upgrade} setting.
*/
public void migrate(boolean forceUpgrade) throws IOException {
StoreVersionCheck versionCheck = storageEngineFactory.versionCheck(fs, databaseLayout, config, pageCache, logService, pageCacheTracer);
LogsUpgrader logsUpgrader = new LogsUpgrader(fs, storageEngineFactory, databaseLayout, pageCache, legacyLogsLocator, config, dependencyResolver, pageCacheTracer, memoryTracker, databaseHealth, forceUpgrade);
Log userLog = logService.getUserLog(DatabaseMigrator.class);
VisibleMigrationProgressMonitor progress = new VisibleMigrationProgressMonitor(userLog);
LogProvider logProvider = logService.getInternalLogProvider();
StoreUpgrader storeUpgrader = new StoreUpgrader(versionCheck, progress, config, fs, logProvider, logsUpgrader, pageCacheTracer);
// Get all the participants from the storage engine and add them where they want to be
var storeParticipants = storageEngineFactory.migrationParticipants(fs, config, pageCache, jobScheduler, logService, pageCacheTracer, memoryTracker);
storeParticipants.forEach(storeUpgrader::addParticipant);
IndexProviderMap indexProviderMap = dependencyResolver.resolveDependency(IndexProviderMap.class);
IndexConfigMigrator indexConfigMigrator = new IndexConfigMigrator(fs, config, pageCache, logService, storageEngineFactory, indexProviderMap, logService.getUserLog(IndexConfigMigrator.class), pageCacheTracer, memoryTracker);
storeUpgrader.addParticipant(indexConfigMigrator);
IndexProviderMigrator indexProviderMigrator = new IndexProviderMigrator(fs, config, pageCache, logService, storageEngineFactory, pageCacheTracer, memoryTracker);
storeUpgrader.addParticipant(indexProviderMigrator);
// Do individual index provider migration last because they may delete files that we need in earlier steps.
indexProviderMap.accept(provider -> storeUpgrader.addParticipant(provider.storeMigrationParticipant(fs, pageCache, storageEngineFactory)));
try {
storeUpgrader.migrateIfNeeded(databaseLayout, forceUpgrade);
} catch (Exception e) {
userLog.error("Error upgrading database. Database left intact and will likely not be able to start: " + e.toString());
throw e;
}
}
Aggregations