private Long[] readRecordsWithNullDefaults( StoreChannel fileChannel, int count, boolean allowUpgrade ) throws IOException { buf.clear(); int bytesRead = fileChannel.read( buf ); int wholeRecordsRead = bytesRead / RECORD_SIZE; if ( wholeRecordsRead < RECORD_COUNT && !allowUpgrade ) { throw new UpgradeNotAllowedByConfigurationException( "Index version (managed by " + file + ") has changed and needs to be upgraded" ); } buf.flip(); Long[] result = new Long[count]; for ( int i = 0; i < wholeRecordsRead; i++ ) { result[i] = buf.getLong(); } return result; }
public UpgradeNotAllowedByConfigurationException() { super( baseMessage() ); }
public static void check( LogTailScanner tailScanner, Config config ) throws UpgradeNotAllowedByConfigurationException { if ( !config.get( GraphDatabaseSettings.allow_upgrade ) ) { // The user doesn't want us to upgrade the store. LogEntryVersion latestLogEntryVersion = tailScanner.getTailInformation().latestLogEntryVersion; if ( latestLogEntryVersion != null && LogEntryVersion.moreRecentVersionExists( latestLogEntryVersion ) ) { String message = "The version you're upgrading to is using a new transaction log format. This is a " + "non-reversible upgrade and you wont be able to downgrade after starting"; throw new UpgradeNotAllowedByConfigurationException( message ); } } } }
public UpgradeNotAllowedByConfigurationException( String msg ) { super( String.format( "%s Detailed description: %s", baseMessage() , msg) ); }
private boolean compareExpectedVersionWithStoreVersion( long expectedVersion, boolean allowUpgrade, Long readIndexVersion ) { boolean versionDiffers = readIndexVersion == null || readIndexVersion != expectedVersion; if ( versionDiffers ) { // We can throw a more explicit exception if we see that we're trying to run // with an older version than the store is. if ( readIndexVersion != null && expectedVersion < readIndexVersion ) { String expected = versionLongToString( expectedVersion ); String readVersion = versionLongToString( readIndexVersion ); 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; }
public UpgradeNotAllowedByConfigurationException() { super( baseMessage() ); }
@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 the configuration. Please set '" + GraphDatabaseSettings.allow_upgrade.name() + "' to 'true' " + "in your configuration file and try again." ) ); } }
public UpgradeNotAllowedByConfigurationException( String msg ) { super( String.format( "%s Detailed description: %s", baseMessage() , msg) ); }
public void migrateIfNeeded( DatabaseLayout layout ) { DatabaseLayout migrationStructure = DatabaseLayout.of( layout.databaseDirectory(), MIGRATION_DIRECTORY ); cleanupLegacyLeftOverDirsIn( layout.databaseDirectory() ); File migrationStateFile = migrationStructure.file( MIGRATION_STATUS_FILE ); // if migration directory exists than we might have failed to move files into the store dir so do it again if ( upgradableDatabase.hasCurrentVersion( layout ) && !fileSystem.fileExists( migrationStateFile ) ) { // No migration needed return; } if ( isUpgradeAllowed() ) { migrateStore( layout, migrationStructure, migrationStateFile ); } else if ( !RecordFormatSelector.isStoreAndConfigFormatsCompatible( config, layout, fileSystem, pageCache, logProvider ) ) { throw new UpgradeNotAllowedByConfigurationException(); } }
private Long[] readRecordsWithNullDefaults( StoreChannel fileChannel, int count, boolean allowUpgrade ) throws IOException { buf.clear(); int bytesRead = fileChannel.read( buf ); int wholeRecordsRead = bytesRead / RECORD_SIZE; if ( wholeRecordsRead < RECORD_COUNT && !allowUpgrade ) { throw new UpgradeNotAllowedByConfigurationException( "Index version (managed by " + file + ") has changed and needs to be upgraded" ); } buf.flip(); Long[] result = new Long[count]; for ( int i = 0; i < wholeRecordsRead; i++ ) { result[i] = buf.getLong(); } return result; }
public static void check( LogTailScanner tailScanner, Config config ) throws UpgradeNotAllowedByConfigurationException { if ( !config.get( GraphDatabaseSettings.allow_upgrade ) ) { // The user doesn't want us to upgrade the store. LogEntryVersion latestLogEntryVersion = tailScanner.getTailInformation().latestLogEntryVersion; if ( latestLogEntryVersion != null && LogEntryVersion.moreRecentVersionExists( latestLogEntryVersion ) ) { String message = "The version you're upgrading to is using a new transaction log format. This is a " + "non-reversible upgrade and you wont be able to downgrade after starting"; throw new UpgradeNotAllowedByConfigurationException( message ); } } } }
private boolean compareExpectedVersionWithStoreVersion( long expectedVersion, boolean allowUpgrade, Long readIndexVersion ) { boolean versionDiffers = readIndexVersion == null || readIndexVersion != expectedVersion; if ( versionDiffers ) { // We can throw a more explicit exception if we see that we're trying to run // with an older version than the store is. if ( readIndexVersion != null && expectedVersion < readIndexVersion ) { String expected = versionLongToString( expectedVersion ); String readVersion = versionLongToString( readIndexVersion ); 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; }
public void migrateIfNeeded( DatabaseLayout layout ) { DatabaseLayout migrationStructure = DatabaseLayout.of( layout.databaseDirectory(), MIGRATION_DIRECTORY ); cleanupLegacyLeftOverDirsIn( layout.databaseDirectory() ); File migrationStateFile = migrationStructure.file( MIGRATION_STATUS_FILE ); // if migration directory exists than we might have failed to move files into the store dir so do it again if ( upgradableDatabase.hasCurrentVersion( layout ) && !fileSystem.fileExists( migrationStateFile ) ) { // No migration needed return; } if ( isUpgradeAllowed() ) { migrateStore( layout, migrationStructure, migrationStateFile ); } else if ( !RecordFormatSelector.isStoreAndConfigFormatsCompatible( config, layout, fileSystem, pageCache, logProvider ) ) { throw new UpgradeNotAllowedByConfigurationException(); } }