use of org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException in project neo4j by neo4j.
the class ServerStartupErrorsTest method shouldDescribeUpgradeFailureInAFriendlyWay.
@Test
public void shouldDescribeUpgradeFailureInAFriendlyWay() {
// given
AssertableLogProvider logging = new AssertableLogProvider();
LifecycleException error = new LifecycleException(new Object(), STARTING, STARTED, new RuntimeException("Error starting org.neo4j.kernel.ha.factory.EnterpriseFacadeFactory", new LifecycleException(new Object(), STARTING, STARTED, new LifecycleException(new Object(), STARTING, STARTED, new UpgradeNotAllowedByConfigurationException()))));
// when
translateToServerStartupError(error).describeTo(logging.getLog("console"));
// then
logging.assertExactly(inLog("console").error("Neo4j cannot be started, because the database files require upgrading and upgrades are " + "disabled in configuration. Please set '%s' to 'true' in your configuration file and try " + "again.", "dbms.allow_format_migration"));
}
use of org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException in project neo4j by neo4j.
the class StoreUpgraderTest method shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess.
@Test
public void shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess() throws IOException {
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
Config deniedMigrationConfig = Config.embeddedDefaults(MapUtil.stringMap(GraphDatabaseSettings.allow_store_upgrade.name(), "false"));
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
try {
newUpgrader(upgradableDatabase, deniedMigrationConfig, pageCache).migrateIfNeeded(dbDirectory);
fail("Should throw exception");
} catch (UpgradeNotAllowedByConfigurationException e) {
// expected
}
}
use of org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException in project neo4j by neo4j.
the class DatabaseStartupTest method startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed.
@Test
public void startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed() throws Throwable {
// given
// create a store
File storeDir = testDirectory.graphDbDir();
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
}
db.shutdown();
// mess up the version in the metadatastore
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem)) {
MetaDataStore.setRecord(pageCache, new File(storeDir, MetaDataStore.DEFAULT_NAME), MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong("bad"));
}
// when
try {
new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir);
fail("It should have failed.");
} catch (RuntimeException ex) {
// then
assertTrue(ex.getCause() instanceof LifecycleException);
assertTrue(ex.getCause().getCause() instanceof UpgradeNotAllowedByConfigurationException);
assertEquals("Failed to start Neo4j with an older data store version. To enable automatic upgrade, " + "please set configuration parameter \"dbms.allow_format_migration=true\"", ex.getCause().getCause().getMessage());
}
}
use of org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException in project neo4j by neo4j.
the class CopiedStoreRecovery method recoverCopiedStore.
public synchronized void recoverCopiedStore(File tempStore) throws StoreCopyFailedException {
if (shutdown) {
throw new StoreCopyFailedException("Abort store-copied store recovery due to database shutdown");
}
try {
GraphDatabaseService graphDatabaseService = newTempDatabase(tempStore);
graphDatabaseService.shutdown();
} catch (Exception e) {
Throwable peeled = Exceptions.peel(e, (t) -> !(t instanceof UpgradeNotAllowedByConfigurationException));
if (peeled != null) {
throw new RuntimeException(failedToStartMessage(), e);
} else {
throw e;
}
}
}
use of org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException in project neo4j by neo4j.
the class IndexProviderStore method compareExpectedVersionWithStoreVersion.
private boolean compareExpectedVersionWithStoreVersion(long expectedVersion, boolean allowUpgrade, Long readIndexVersion) {
boolean versionDiffers = readIndexVersion == null || readIndexVersion.longValue() != expectedVersion;
if (versionDiffers) {
// with an older version than the store is.
if (readIndexVersion != null && expectedVersion < readIndexVersion.longValue()) {
String expected = versionLongToString(expectedVersion);
String readVersion = versionLongToString(readIndexVersion.longValue());
throw new NotCurrentStoreVersionException(expected, readVersion, "Your index has been upgraded to " + readVersion + " and cannot run with an older version " + expected, false);
} else if (!allowUpgrade) {
// We try to run with a newer version than the store is but isn't allowed to upgrade.
throw new UpgradeNotAllowedByConfigurationException();
}
}
return versionDiffers;
}
Aggregations