use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class ConsistencyCheckServiceIntegrationTest method tracePageCacheAccessOnConsistencyCheck.
@Test
void tracePageCacheAccessOnConsistencyCheck() throws ConsistencyCheckIncompleteException {
prepareDbWithDeletedRelationshipPartOfTheChain();
ConsistencyCheckService service = new ConsistencyCheckService(new Date());
var pageCacheTracer = new DefaultPageCacheTracer();
fixture.close();
JobScheduler jobScheduler = JobSchedulerFactory.createScheduler();
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(testDirectory.getFileSystem(), Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m"), pageCacheTracer, NullLog.getInstance(), jobScheduler, Clocks.nanoClock(), new MemoryPools(false));
try (Lifespan life = new Lifespan(jobScheduler);
PageCache pageCache = pageCacheFactory.getOrCreatePageCache()) {
var result = service.runFullConsistencyCheck(fixture.databaseLayout(), Config.defaults(settings()), ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), testDirectory.getFileSystem(), pageCache, false, ConsistencyFlags.DEFAULT, pageCacheTracer, INSTANCE);
assertFalse(result.isSuccessful());
assertThat(pageCacheTracer.pins()).isGreaterThanOrEqualTo(74);
assertThat(pageCacheTracer.unpins()).isGreaterThanOrEqualTo(74);
assertThat(pageCacheTracer.hits()).isGreaterThanOrEqualTo(35);
assertThat(pageCacheTracer.faults()).isGreaterThanOrEqualTo(39);
}
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class IndexPopulationJobTest method before.
@BeforeEach
void before() throws Exception {
kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
tokens = db.getDependencyResolver().resolveDependency(TokenNameLookup.class);
tokenHolders = db.getDependencyResolver().resolveDependency(TokenHolders.class);
stateHolder = new DatabaseSchemaState(NullLogProvider.getInstance());
IndexingService indexingService = db.getDependencyResolver().resolveDependency(IndexingService.class);
indexStoreView = db.getDependencyResolver().resolveDependency(IndexStoreViewFactory.class).createTokenIndexStoreView(indexingService::getIndexProxy);
indexStatisticsStore = db.getDependencyResolver().resolveDependency(IndexStatisticsStore.class);
jobScheduler = db.getDependencyResolver().resolveDependency(JobScheduler.class);
try (KernelTransaction tx = kernel.beginTransaction(IMPLICIT, LoginContext.AUTH_DISABLED)) {
labelId = tx.tokenWrite().labelGetOrCreateForName(FIRST.name());
tx.tokenWrite().labelGetOrCreateForName(SECOND.name());
tx.commit();
}
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class FullCheckFulltextIndexEmptyDocs method check.
private ConsistencyCheckService.Result check(Config config, DatabaseLayout layout) throws Exception {
JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fs, config, NULL, NullLog.getInstance(), jobScheduler, Clocks.nanoClock(), new MemoryPools(config.get(memory_tracking)));
PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
ConsistencyCheckService.Result result;
try {
result = new ConsistencyCheckService().runFullConsistencyCheck(layout, config, NONE, NullLogProvider.getInstance(), fs, pageCache, DebugContext.NO_DEBUG, layout.databaseDirectory(), DEFAULT, NULL, INSTANCE);
} finally {
pageCache.close();
jobScheduler.close();
}
return result;
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class GBPTreeBootstrapperTest method shouldBootstrapTreeOfDifferentPageSizes.
@ParameterizedTest
@MethodSource("testSetupStream")
void shouldBootstrapTreeOfDifferentPageSizes(TestSetup testSetup) throws Exception {
setupTest(testSetup);
ZipUtils.unzipResource(getClass(), zipName, storeFile);
LayoutBootstrapper layoutBootstrapper = (indexFile, pageCache, meta) -> layout;
try (JobScheduler scheduler = new ThreadPoolJobScheduler();
GBPTreeBootstrapper bootstrapper = new GBPTreeBootstrapper(fs, scheduler, layoutBootstrapper, readOnly(), PageCacheTracer.NULL)) {
GBPTreeBootstrapper.Bootstrap bootstrap = bootstrapper.bootstrapTree(storeFile);
assertTrue(bootstrap.isTree());
try (GBPTree<?, ?> tree = bootstrap.getTree()) {
assertTrue(tree.consistencyCheck(CursorContext.NULL));
}
}
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class IndexingServiceTest method shouldNotHaveToWaitForOrphanedUniquenessIndexInRecovery.
@Test
void shouldNotHaveToWaitForOrphanedUniquenessIndexInRecovery() throws Exception {
// given that we have a uniqueness index that needs to be recovered and that doesn't have a constraint attached to it
IndexDescriptor descriptor = uniqueIndex.materialise(10);
Iterable<IndexDescriptor> schemaRules = Collections.singletonList(descriptor);
IndexProvider indexProvider = mock(IndexProvider.class);
when(indexProvider.getInitialState(any(), any())).thenReturn(POPULATING);
IndexProviderMap indexProviderMap = mock(IndexProviderMap.class);
when(indexProviderMap.lookup(anyString())).thenReturn(indexProvider);
when(indexProviderMap.lookup(any(IndexProviderDescriptor.class))).thenReturn(indexProvider);
when(indexProviderMap.getDefaultProvider()).thenReturn(indexProvider);
NullLogProvider logProvider = NullLogProvider.getInstance();
IndexMapReference indexMapReference = new IndexMapReference();
IndexProxyCreator indexProxyCreator = mock(IndexProxyCreator.class);
IndexProxy indexProxy = mock(IndexProxy.class);
when(indexProxy.getDescriptor()).thenReturn(descriptor);
// Eventually return ONLINE so that this test won't hang if the product code changes in this regard.
// This test should still fail below when verifying interactions with the proxy and monitor tho.
when(indexProxy.getState()).thenReturn(POPULATING, POPULATING, POPULATING, POPULATING, ONLINE);
when(indexProxyCreator.createRecoveringIndexProxy(any())).thenReturn(indexProxy);
when(indexProxyCreator.createFailedIndexProxy(any(), any())).thenReturn(indexProxy);
when(indexProxyCreator.createPopulatingIndexProxy(any(), anyBoolean(), any(), any())).thenReturn(indexProxy);
JobScheduler scheduler = mock(JobScheduler.class);
IndexSamplingController samplingController = mock(IndexSamplingController.class);
IndexingService.Monitor monitor = mock(IndexingService.Monitor.class);
IndexStoreViewFactory storeViewFactory = mock(IndexStoreViewFactory.class);
when(storeViewFactory.createTokenIndexStoreView(any())).thenReturn(storeView);
when(storeView.newPropertyAccessor(any(), any())).thenReturn(propertyAccessor);
IndexingService indexingService = new IndexingService(indexProxyCreator, indexProviderMap, indexMapReference, storeViewFactory, schemaRules, samplingController, nameLookup, scheduler, null, logProvider, logProvider, monitor, mock(IndexStatisticsStore.class), PageCacheTracer.NULL, INSTANCE, "", writable(), Config.defaults());
// and where index population starts
indexingService.init();
// when starting the indexing service
indexingService.start();
// then it should be able to start without awaiting the completion of the population of the index
verify(indexProxy, never()).awaitStoreScanCompleted(anyLong(), any());
verify(monitor, never()).awaitingPopulationOfRecoveredIndex(any());
}
Aggregations