Skip to content

Commit

Permalink
Always place the new counts store in migration dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed Jul 5, 2017
1 parent df930a9 commit 73bdd43
Showing 1 changed file with 13 additions and 9 deletions.
Expand Up @@ -58,8 +58,8 @@
* Rebuilds the count store during migration. * Rebuilds the count store during migration.
* <p> * <p>
* Since the database may or may not reside in the upgrade directory, depending on whether the new format has * Since the database may or may not reside in the upgrade directory, depending on whether the new format has
* different capabilities or not, we rebuild the count store in the store directory if we fail to open the store in * different capabilities or not, we rebuild the count store using the information the store directory if we fail to
* the upgrade directory * open the store in the upgrade directory.
* <p> * <p>
* Just one out of many potential participants in a {@link StoreUpgrader migration}. * Just one out of many potential participants in a {@link StoreUpgrader migration}.
* *
Expand All @@ -68,7 +68,7 @@
public class CountsMigrator extends AbstractStoreMigrationParticipant public class CountsMigrator extends AbstractStoreMigrationParticipant
{ {


public static final Iterable<StoreFile> COUNTS_STORE_FILES = Iterables private static final Iterable<StoreFile> COUNTS_STORE_FILES = Iterables
.iterable( StoreFile.COUNTS_STORE_LEFT, StoreFile.COUNTS_STORE_RIGHT ); .iterable( StoreFile.COUNTS_STORE_LEFT, StoreFile.COUNTS_STORE_RIGHT );
private final Config config; private final Config config;
private final LogService logService; private final LogService logService;
Expand Down Expand Up @@ -97,13 +97,16 @@ public void migrate( File storeDir, File migrationDir, MigrationProgressMonitor.
long lastTxId = MetaDataStore.getRecord( pageCache, neoStore, Position.LAST_TRANSACTION_ID ); long lastTxId = MetaDataStore.getRecord( pageCache, neoStore, Position.LAST_TRANSACTION_ID );
try try
{ {
rebuildCountsFromScratch( migrationDir, lastTxId, progressMonitor, versionToMigrateTo, pageCache ); rebuildCountsFromScratch( migrationDir, migrationDir, lastTxId, progressMonitor, versionToMigrateTo,
pageCache );
} }
catch ( StoreFailureException e ) catch ( StoreFailureException e )
{ {
//This means that we did not perform a full migration, as the formats had the same capabilities. Thus //This means that we did not perform a full migration, as the formats had the same capabilities. Thus
// we should use the store directory for information when rebuilding the count store. // we should use the store directory for information when rebuilding the count store. Note that we
rebuildCountsFromScratch( storeDir, lastTxId, progressMonitor, versionToMigrateFrom, pageCache ); // still put the new count store in the migration directory.
rebuildCountsFromScratch( storeDir, migrationDir, lastTxId, progressMonitor, versionToMigrateFrom,
pageCache );
} }
} }
} }
Expand Down Expand Up @@ -141,13 +144,14 @@ boolean countStoreRebuildRequired( String versionToMigrateFrom )
StoreVersion.HIGH_LIMIT_V3_1_0.versionString().equals( versionToMigrateFrom ); StoreVersion.HIGH_LIMIT_V3_1_0.versionString().equals( versionToMigrateFrom );
} }


private void rebuildCountsFromScratch( File migrationDir, long lastTxId, private void rebuildCountsFromScratch( File storeDirToReadFrom, File migrationDir, long lastTxId,
MigrationProgressMonitor.Section progressMonitor, String expectedStoreVersion, PageCache pageCache ) MigrationProgressMonitor.Section progressMonitor, String expectedStoreVersion, PageCache pageCache )
{ {
final File storeFileBase = new File( migrationDir, MetaDataStore.DEFAULT_NAME + StoreFactory.COUNTS_STORE ); final File storeFileBase = new File( migrationDir,
MetaDataStore.DEFAULT_NAME + StoreFactory.COUNTS_STORE );


RecordFormats recordFormats = selectForVersion( expectedStoreVersion ); RecordFormats recordFormats = selectForVersion( expectedStoreVersion );
StoreFactory storeFactory = new StoreFactory( migrationDir, pageCache, fileSystem, recordFormats, StoreFactory storeFactory = new StoreFactory( storeDirToReadFrom, pageCache, fileSystem, recordFormats,
NullLogProvider.getInstance() ); NullLogProvider.getInstance() );
try ( NeoStores neoStores = storeFactory try ( NeoStores neoStores = storeFactory
.openNeoStores( StoreType.NODE, StoreType.RELATIONSHIP, StoreType.LABEL_TOKEN, .openNeoStores( StoreType.NODE, StoreType.RELATIONSHIP, StoreType.LABEL_TOKEN,
Expand Down

0 comments on commit 73bdd43

Please sign in to comment.