Skip to content

Commit

Permalink
Update format verification to allow compatible formats of higher gene…
Browse files Browse the repository at this point in the history
…ration to be used on top of the stores with more obsolete format.
  • Loading branch information
MishaDemianenko committed Sep 13, 2016
1 parent f9933b1 commit c7bc207
Showing 1 changed file with 14 additions and 4 deletions.
Expand Up @@ -41,6 +41,9 @@
import org.neo4j.kernel.impl.api.CountsAccessor; import org.neo4j.kernel.impl.api.CountsAccessor;
import org.neo4j.kernel.impl.store.counts.CountsTracker; import org.neo4j.kernel.impl.store.counts.CountsTracker;
import org.neo4j.kernel.impl.store.counts.ReadOnlyCountsTracker; import org.neo4j.kernel.impl.store.counts.ReadOnlyCountsTracker;
import org.neo4j.kernel.impl.store.format.CapabilityType;
import org.neo4j.kernel.impl.store.format.FormatFamily;
import org.neo4j.kernel.impl.store.format.RecordFormatSelector;
import org.neo4j.kernel.impl.store.format.RecordFormats; import org.neo4j.kernel.impl.store.format.RecordFormats;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory; import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.impl.store.id.IdType; import org.neo4j.kernel.impl.store.id.IdType;
Expand Down Expand Up @@ -168,12 +171,12 @@ private void verifyRecordFormat()
{ {
try try
{ {
String expectedStoreVersion = recordFormats.storeVersion(); String storeVersion = versionLongToString( getRecord( pageCache, neoStoreFileName, STORE_VERSION ) );
String actualStoreVersion = versionLongToString( getRecord( pageCache, neoStoreFileName, STORE_VERSION ) ); RecordFormats storeFormat = RecordFormatSelector.selectForVersion( storeVersion );
if ( !expectedStoreVersion.equals( actualStoreVersion ) ) if ( !isCompatibleFormats( storeFormat ) )
{ {
throw new StoreUpgrader.UnexpectedUpgradingStoreVersionException( neoStoreFileName.getName(), throw new StoreUpgrader.UnexpectedUpgradingStoreVersionException( neoStoreFileName.getName(),
actualStoreVersion ); storeVersion );
} }
} }
catch ( NoSuchFileException e ) catch ( NoSuchFileException e )
Expand All @@ -188,6 +191,13 @@ private void verifyRecordFormat()
} }
} }


private boolean isCompatibleFormats( RecordFormats storeFormat )
{
return FormatFamily.isSameFamily( recordFormats, storeFormat ) &&
recordFormats.hasSameCapabilities( storeFormat, CapabilityType.FORMAT ) &&
recordFormats.generation() >= storeFormat.generation();
}

private void closeStore( StoreType type ) private void closeStore( StoreType type )
{ {
int i = type.ordinal(); int i = type.ordinal();
Expand Down

0 comments on commit c7bc207

Please sign in to comment.