use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class NeoStoreDataSourceTest method flushOfThePageCacheOnShutdownHappensIfTheDbIsHealthy.
@Test
public void flushOfThePageCacheOnShutdownHappensIfTheDbIsHealthy() throws IOException {
DatabaseHealth health = mock(DatabaseHealth.class);
when(health.isHealthy()).thenReturn(true);
PageCache pageCache = spy(pageCacheRule.getPageCache(fs.get()));
NeoStoreDataSource ds = dsRule.getDataSource(dir.graphDbDir(), fs.get(), pageCache, stringMap(), health);
ds.init();
ds.start();
verify(pageCache, never()).flushAndForce();
ds.stop();
ds.shutdown();
verify(pageCache).flushAndForce(IOLimiter.unlimited());
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class RunOutOfDiskSpaceIT method shouldPropagateIOExceptions.
@Test
public void shouldPropagateIOExceptions() throws Exception {
// Given
TransactionFailureException exceptionThrown = null;
File storeDir = testDirectory.absolutePath();
LimitedFileSystemGraphDatabase db = new LimitedFileSystemGraphDatabase(storeDir);
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
}
long logVersion = db.getDependencyResolver().resolveDependency(LogVersionRepository.class).getCurrentLogVersion();
db.runOutOfDiskSpaceNao();
// When
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
} catch (TransactionFailureException e) {
exceptionThrown = e;
} finally {
Assert.assertNotNull("Expected tx finish to throw TransactionFailureException when filesystem is full.", exceptionThrown);
assertTrue(Exceptions.contains(exceptionThrown, IOException.class));
}
// to help shutting down the db
db.somehowGainMoreDiskSpace();
db.shutdown();
PageCache pageCache = pageCacheRule.getPageCache(db.getFileSystem());
File neoStore = new File(storeDir, MetaDataStore.DEFAULT_NAME);
assertEquals(logVersion, MetaDataStore.getRecord(pageCache, neoStore, MetaDataStore.Position.LOG_VERSION));
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class RunOutOfDiskSpaceIT method shouldStopDatabaseWhenOutOfDiskSpace.
@Test
public void shouldStopDatabaseWhenOutOfDiskSpace() throws Exception {
// Given
TransactionFailureException expectedCommitException = null;
TransactionFailureException expectedStartException = null;
File storeDir = testDirectory.absolutePath();
LimitedFileSystemGraphDatabase db = cleanup.add(new LimitedFileSystemGraphDatabase(storeDir));
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
}
long logVersion = db.getDependencyResolver().resolveDependency(LogVersionRepository.class).getCurrentLogVersion();
db.runOutOfDiskSpaceNao();
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
} catch (TransactionFailureException e) {
expectedCommitException = e;
} finally {
Assert.assertNotNull("Expected tx finish to throw TransactionFailureException when filesystem is full.", expectedCommitException);
}
// When
try (Transaction transaction = db.beginTx()) {
fail("Expected tx begin to throw TransactionFailureException when tx manager breaks.");
} catch (TransactionFailureException e) {
expectedStartException = e;
} finally {
Assert.assertNotNull("Expected tx begin to throw TransactionFailureException when tx manager breaks.", expectedStartException);
}
// Then
// to help shutting down the db
db.somehowGainMoreDiskSpace();
db.shutdown();
PageCache pageCache = pageCacheRule.getPageCache(db.getFileSystem());
File neoStore = new File(storeDir, MetaDataStore.DEFAULT_NAME);
assertEquals(logVersion, MetaDataStore.getRecord(pageCache, neoStore, MetaDataStore.Position.LOG_VERSION));
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class BatchingNeoStores method batchingNeoStores.
public static BatchingNeoStores batchingNeoStores(FileSystemAbstraction fileSystem, File storeDir, RecordFormats recordFormats, Configuration config, LogService logService, AdditionalInitialIds initialIds, Config dbConfig) {
Config neo4jConfig = getNeo4jConfig(config, dbConfig);
final PageCacheTracer tracer = new DefaultPageCacheTracer();
PageCache pageCache = createPageCache(fileSystem, neo4jConfig, logService.getInternalLogProvider(), tracer, DefaultPageCursorTracerSupplier.INSTANCE);
BatchingNeoStores batchingNeoStores = new BatchingNeoStores(fileSystem, pageCache, storeDir, recordFormats, neo4jConfig, logService, initialIds, false, tracer::bytesWritten);
return batchingNeoStores;
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ConsistencyCheckService method runFullConsistencyCheck.
public Result runFullConsistencyCheck(File storeDir, Config config, ProgressMonitorFactory progressFactory, LogProvider logProvider, FileSystemAbstraction fileSystem, boolean verbose, File reportDir, CheckConsistencyConfig checkConsistencyConfig) throws ConsistencyCheckIncompleteException, IOException {
Log log = logProvider.getLog(getClass());
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, logProvider.getLog(PageCache.class));
PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
try {
return runFullConsistencyCheck(storeDir, config, progressFactory, logProvider, fileSystem, pageCache, verbose, reportDir, checkConsistencyConfig);
} finally {
try {
pageCache.close();
} catch (Exception e) {
log.error("Failure during shutdown of the page cache", e);
}
}
}
Aggregations