Search in sources :

Example 1 with UpgradeNotAllowedByConfigurationException

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"));
}
Also used : UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) LifecycleException(org.neo4j.kernel.lifecycle.LifecycleException) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 2 with UpgradeNotAllowedByConfigurationException

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
    }
}
Also used : UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) Config(org.neo4j.kernel.configuration.Config) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 3 with UpgradeNotAllowedByConfigurationException

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());
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) LifecycleException(org.neo4j.kernel.lifecycle.LifecycleException) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Transaction(org.neo4j.graphdb.Transaction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 4 with UpgradeNotAllowedByConfigurationException

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;
        }
    }
}
Also used : PageCache(org.neo4j.io.pagecache.PageCache) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) Config(org.neo4j.kernel.configuration.Config) Exceptions(org.neo4j.helpers.Exceptions) Settings(org.neo4j.kernel.configuration.Settings) NullLogProvider(org.neo4j.logging.NullLogProvider) File(java.io.File) LabelIndex(org.neo4j.graphdb.factory.GraphDatabaseSettings.LabelIndex) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) ExternallyManagedPageCache.graphDatabaseFactoryWithPageCache(org.neo4j.com.storecopy.ExternallyManagedPageCache.graphDatabaseFactoryWithPageCache) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException)

Example 5 with UpgradeNotAllowedByConfigurationException

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;
}
Also used : UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) NotCurrentStoreVersionException(org.neo4j.kernel.impl.store.NotCurrentStoreVersionException) MetaDataStore.versionLongToString(org.neo4j.kernel.impl.store.MetaDataStore.versionLongToString)

Aggregations

UpgradeNotAllowedByConfigurationException (org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException)5 Test (org.junit.Test)3 PageCache (org.neo4j.io.pagecache.PageCache)3 File (java.io.File)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 Config (org.neo4j.kernel.configuration.Config)2 LifecycleException (org.neo4j.kernel.lifecycle.LifecycleException)2 ExternallyManagedPageCache.graphDatabaseFactoryWithPageCache (org.neo4j.com.storecopy.ExternallyManagedPageCache.graphDatabaseFactoryWithPageCache)1 Transaction (org.neo4j.graphdb.Transaction)1 GraphDatabaseSettings (org.neo4j.graphdb.factory.GraphDatabaseSettings)1 LabelIndex (org.neo4j.graphdb.factory.GraphDatabaseSettings.LabelIndex)1 Exceptions (org.neo4j.helpers.Exceptions)1 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 Settings (org.neo4j.kernel.configuration.Settings)1 KernelExtensionFactory (org.neo4j.kernel.extension.KernelExtensionFactory)1 MetaDataStore.versionLongToString (org.neo4j.kernel.impl.store.MetaDataStore.versionLongToString)1 NotCurrentStoreVersionException (org.neo4j.kernel.impl.store.NotCurrentStoreVersionException)1 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)1 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)1