NativeLabelScanStore( PageCache pageCache, DatabaseLayout directoryStructure, FileSystemAbstraction fs, FullStoreChangeStream fullStoreChangeStream, boolean readOnly, Monitors monitors, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, int pageSize ) { this.pageCache = pageCache; this.fs = fs; this.pageSize = pageSize; this.fullStoreChangeStream = fullStoreChangeStream; this.directoryStructure = directoryStructure; this.storeFile = getLabelScanStoreFile( directoryStructure ); this.readOnly = readOnly; this.monitors = monitors; this.monitor = monitors.newMonitor( Monitor.class ); this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector; this.fileSystem = fs; }
private void deleteNativeIndexFile( DatabaseLayout directoryStructure ) throws IOException { Optional<FileHandle> indexFile = fileSystem.streamFilesRecursive( NativeLabelScanStore.getLabelScanStoreFile( directoryStructure ) ).findFirst(); if ( indexFile.isPresent() ) { try { indexFile.get().delete(); } catch ( NoSuchFileException e ) { // Already deleted, ignore } } }
/** * Called when expecting a clean {@code storeDir} folder and where a new store will be created. * This happens on an initial attempt to import. * * @throws IOException on I/O error. * @throws IllegalStateException if {@code storeDir} already contains a database. */ public void createNew() throws IOException { assertDatabaseIsEmptyOrNonExistent(); // There may have been a previous import which was killed before it even started, where the label scan store could // be in a semi-initialized state. Better to be on the safe side and deleted it. We get her after determining that // the db is either completely empty or non-existent anyway, so deleting this file is OK. fileSystem.deleteFile( getLabelScanStoreFile( databaseLayout ) ); instantiateStores(); neoStores.getMetaDataStore().setLastCommittedAndClosedTransactionId( initialIds.lastCommittedTransactionId(), initialIds.lastCommittedTransactionChecksum(), BASE_TX_COMMIT_TIMESTAMP, initialIds.lastCommittedTransactionLogByteOffset(), initialIds.lastCommittedTransactionLogVersion() ); neoStores.startCountStore(); }
@Test public void shouldRestartPopulationIfIndexFileWasNeverFullyInitialized() throws IOException { // given File labelScanStoreFile = NativeLabelScanStore.getLabelScanStoreFile( testDirectory.databaseLayout() ); fileSystemRule.create( labelScanStoreFile ).close(); TrackingMonitor monitor = new TrackingMonitor(); LifeSupport life = new LifeSupport(); // when life.add( createLabelScanStore( fileSystemRule.get(), testDirectory.databaseLayout(), EMPTY, true, false, monitor ) ); life.start(); // then assertTrue( monitor.corruptedIndex ); assertTrue( monitor.rebuildingCalled ); life.shutdown(); } }
NativeLabelScanStore( PageCache pageCache, DatabaseLayout directoryStructure, FileSystemAbstraction fs, FullStoreChangeStream fullStoreChangeStream, boolean readOnly, Monitors monitors, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, int pageSize ) { this.pageCache = pageCache; this.fs = fs; this.pageSize = pageSize; this.fullStoreChangeStream = fullStoreChangeStream; this.directoryStructure = directoryStructure; this.storeFile = getLabelScanStoreFile( directoryStructure ); this.readOnly = readOnly; this.monitors = monitors; this.monitor = monitors.newMonitor( Monitor.class ); this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector; this.fileSystem = fs; }
private void deleteNativeIndexFile( DatabaseLayout directoryStructure ) throws IOException { Optional<FileHandle> indexFile = fileSystem.streamFilesRecursive( NativeLabelScanStore.getLabelScanStoreFile( directoryStructure ) ).findFirst(); if ( indexFile.isPresent() ) { try { indexFile.get().delete(); } catch ( NoSuchFileException e ) { // Already deleted, ignore } } }
/** * Called when expecting a clean {@code storeDir} folder and where a new store will be created. * This happens on an initial attempt to import. * * @throws IOException on I/O error. * @throws IllegalStateException if {@code storeDir} already contains a database. */ public void createNew() throws IOException { assertDatabaseIsEmptyOrNonExistent(); // There may have been a previous import which was killed before it even started, where the label scan store could // be in a semi-initialized state. Better to be on the safe side and deleted it. We get her after determining that // the db is either completely empty or non-existent anyway, so deleting this file is OK. fileSystem.deleteFile( getLabelScanStoreFile( databaseLayout ) ); instantiateStores(); neoStores.getMetaDataStore().setLastCommittedAndClosedTransactionId( initialIds.lastCommittedTransactionId(), initialIds.lastCommittedTransactionChecksum(), BASE_TX_COMMIT_TIMESTAMP, initialIds.lastCommittedTransactionLogByteOffset(), initialIds.lastCommittedTransactionLogVersion() ); neoStores.startCountStore(); }