Search in sources :

Example 11 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class TokenIndexPopulatorCompatibility method shouldReportInitialStateAsFailedIfPopulationFailed.

@Test
public void shouldReportInitialStateAsFailedIfPopulationFailed() throws Exception {
    // GIVEN
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> {
        String failure = "The contrived failure";
        // WHEN
        p.markAsFailed(failure);
        p.close(false, NULL);
        // THEN
        assertEquals(FAILED, indexProvider.getInitialState(descriptor, NULL));
    }, false);
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) Test(org.junit.Test)

Example 12 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldNotReportIndexInconsistenciesIfIndexIsFailed.

@Test
void shouldNotReportIndexInconsistenciesIfIndexIsFailed() throws Exception {
    // this test fails all indexes, and then destroys a record and makes sure we only get a failure for
    // the label scan store but not for any index
    // given
    DirectStoreAccess storeAccess = fixture.directStoreAccess();
    // fail all indexes
    Iterator<IndexDescriptor> rules = getValueIndexDescriptors();
    while (rules.hasNext()) {
        IndexDescriptor rule = rules.next();
        IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.defaults());
        IndexPopulator populator = storeAccess.indexes().lookup(rule.getIndexProvider()).getPopulator(rule, samplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup);
        populator.markAsFailed("Oh noes! I was a shiny index and then I was failed");
        populator.close(false, NULL);
    }
    for (Long indexedNodeId : indexedNodes) {
        storeAccess.nativeStores().getNodeStore().updateRecord(notInUse(new NodeRecord(indexedNodeId).initialize(false, -1, false, -1, 0)), NULL);
    }
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    // the label scan is pointing to 2 nodes not in use
    on(stats).verify(RecordType.LABEL_SCAN_DOCUMENT, 2).verify(RecordType.COUNTS, 2).andThatsAllFolks();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) DirectStoreAccess(org.neo4j.consistency.store.DirectStoreAccess) AtomicLong(java.util.concurrent.atomic.AtomicLong) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 13 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class IndexIteratorIT method setUp.

@BeforeEach
void setUp() throws IOException {
    var label = label("any");
    var propertyName = "property";
    try (var tx = database.beginTx()) {
        var node = tx.createNode(label);
        node.setProperty(propertyName, "nodeValue");
        tx.commit();
    }
    try (var tx = database.beginTx()) {
        tx.schema().indexFor(label).on(propertyName).withName(INDEX_NAME).create();
        tx.commit();
    }
    try (var transaction = database.beginTx()) {
        transaction.schema().awaitIndexesOnline(10, MINUTES);
    }
    var neoStores = storageEngine.testAccessNeoStores();
    indexAccessors = new IndexAccessors(providerMap, neoStores, new IndexSamplingConfig(config), PageCacheTracer.NULL, SIMPLE_NAME_LOOKUP, () -> KernelVersion.LATEST);
    pageCacheTracer = new DefaultPageCacheTracer();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class NodeCheckerIT method prepareContext.

private void prepareContext() throws Exception {
    var neoStores = storageEngine.testAccessNeoStores();
    var indexAccessors = new IndexAccessors(providerMap, neoStores, new IndexSamplingConfig(config), PageCacheTracer.NULL, SIMPLE_NAME_LOOKUP, () -> KernelVersion.LATEST);
    context = new CheckerContext(neoStores, indexAccessors, execution, mock(ConsistencyReport.Reporter.class, RETURNS_MOCKS), CacheAccess.EMPTY, tokenHolders, mock(RecordLoading.class), mock(CountsState.class), mock(NodeBasedMemoryLimiter.class), ProgressMonitorFactory.NONE.multipleParts("test"), pageCache, pageCacheTracer, INSTANCE, DebugContext.NO_DEBUG, ConsistencyFlags.DEFAULT);
    context.initialize();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) IndexAccessors(org.neo4j.consistency.checking.index.IndexAccessors) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport)

Example 15 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class RelationshipCheckerIT method prepareContext.

private void prepareContext() throws Exception {
    var neoStores = storageEngine.testAccessNeoStores();
    var indexAccessors = new IndexAccessors(providerMap, neoStores, new IndexSamplingConfig(config), PageCacheTracer.NULL, SIMPLE_NAME_LOOKUP, () -> KernelVersion.LATEST);
    context = new CheckerContext(neoStores, indexAccessors, execution, mock(ConsistencyReport.Reporter.class, RETURNS_MOCKS), CacheAccess.EMPTY, tokenHolders, mock(RecordLoading.class), mock(CountsState.class), mock(NodeBasedMemoryLimiter.class), ProgressMonitorFactory.NONE.multipleParts("test"), pageCache, pageCacheTracer, INSTANCE, DebugContext.NO_DEBUG, ConsistencyFlags.DEFAULT);
    context.initialize();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) IndexAccessors(org.neo4j.consistency.checking.index.IndexAccessors) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport)

Aggregations

IndexSamplingConfig (org.neo4j.kernel.impl.api.index.IndexSamplingConfig)15 Test (org.junit.Test)7 BeforeEach (org.junit.jupiter.api.BeforeEach)3 IndexAccessors (org.neo4j.consistency.checking.index.IndexAccessors)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)2 Monitors (org.neo4j.monitoring.Monitors)2 Path (java.nio.file.Path)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ByteBuffersDirectory (org.apache.lucene.store.ByteBuffersDirectory)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 DependencyResolver (org.neo4j.common.DependencyResolver)1 Config (org.neo4j.configuration.Config)1 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)1 LookupAccessorsFromRunningDb (org.neo4j.consistency.LookupAccessorsFromRunningDb)1 ConsistencyReporter (org.neo4j.consistency.report.ConsistencyReporter)1 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 InconsistencyMessageLogger (org.neo4j.consistency.report.InconsistencyMessageLogger)1 InconsistencyReport (org.neo4j.consistency.report.InconsistencyReport)1