Search in sources :

Example 1 with LuceneIndexProvider

use of org.neo4j.kernel.api.impl.schema.LuceneIndexProvider in project neo4j by neo4j.

the class LuceneIndexSamplerReleaseTaskControlUnderFusionTest method failedIndexSamplingMustNotPreventIndexDrop.

/**
 * This test come from a support case where dropping an index would block forever after index sampling failed.
 * <p>
 * A fusion index has multiple {@link IndexSampler index samplers} that are called sequentially. If one fails, then the other will never be invoked.
 * This was a problem for {@link LuceneIndexSampler}. It owns a {@link TaskCoordinator.Task} that it will try to release in try-finally
 * in {@link LuceneIndexSampler#sampleIndex(CursorContext)}. But it never gets here because a prior {@link IndexSampler} fails.
 * <p>
 * Because the {@link TaskCoordinator.Task} was never released the lucene accessor would block forever, waiting for
 * {@link TaskCoordinator#awaitCompletion()}.
 * <p>
 * This situation was solved by making {@link IndexSampler} {@link java.io.Closeable} and include it in try-with-resource together with
 * {@link IndexReader} that created it.
 */
@Test
void failedIndexSamplingMustNotPreventIndexDrop() throws IOException, IndexEntryConflictException {
    LuceneIndexProvider luceneProvider = luceneProvider();
    // Otherwise no sampler will be created.
    makeSureIndexHasSomeData(luceneProvider);
    IndexProvider failingProvider = failingProvider();
    FusionIndexProvider fusionProvider = createFusionProvider(luceneProvider, failingProvider);
    try (IndexAccessor fusionAccessor = fusionProvider.getOnlineAccessor(descriptor, samplingConfig, tokenNameLookup)) {
        IndexSamplingJob indexSamplingJob = createIndexSamplingJob(fusionAccessor);
        // Call run from other thread
        try {
            indexSamplingJob.run();
        } catch (RuntimeException e) {
            assertSame(sampleException, e);
        }
        // then
        fusionAccessor.drop();
    // should not block forever
    }
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) LuceneIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneIndexProvider) FusionIndexProvider(org.neo4j.kernel.impl.index.schema.fusion.FusionIndexProvider) IndexSamplingJob(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingJob) FusionIndexProvider(org.neo4j.kernel.impl.index.schema.fusion.FusionIndexProvider) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) LuceneIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneIndexProvider) Test(org.junit.jupiter.api.Test)

Example 2 with LuceneIndexProvider

use of org.neo4j.kernel.api.impl.schema.LuceneIndexProvider in project neo4j by neo4j.

the class NonUniqueLuceneIndexPopulatingUpdaterIT method createIndexProvider.

private LuceneIndexProvider createIndexProvider() {
    var directoryFactory = new DirectoryFactory.InMemoryDirectoryFactory();
    var directoryStructureFactory = directoriesByProvider(testDir.homePath());
    return new LuceneIndexProvider(fileSystem, directoryFactory, directoryStructureFactory, new Monitors(), Config.defaults(), writable());
}
Also used : Monitors(org.neo4j.monitoring.Monitors) LuceneIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneIndexProvider)

Example 3 with LuceneIndexProvider

use of org.neo4j.kernel.api.impl.schema.LuceneIndexProvider in project neo4j by neo4j.

the class NativeLuceneFusionIndexProviderFactory30 method create.

@VisibleForTesting
public static FusionIndexProvider create(PageCache pageCache, Path databaseDirectory, FileSystemAbstraction fs, Monitors monitors, String monitorTag, Config config, DatabaseReadOnlyChecker readOnlyChecker, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, PageCacheTracer pageCacheTracer, String databaseName) {
    IndexDirectoryStructure.Factory childDirectoryStructure = subProviderDirectoryStructure(databaseDirectory);
    boolean archiveFailedIndex = config.get(GraphDatabaseInternalSettings.archive_failed_index);
    DatabaseIndexContext databaseIndexContext = DatabaseIndexContext.builder(pageCache, fs, databaseName).withMonitors(monitors).withTag(monitorTag).withReadOnlyChecker(readOnlyChecker).withPageCacheTracer(pageCacheTracer).build();
    GenericNativeIndexProvider generic = new GenericNativeIndexProvider(databaseIndexContext, childDirectoryStructure, recoveryCleanupWorkCollector, config);
    LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider(fs, childDirectoryStructure, monitors, monitorTag, config, readOnlyChecker);
    return new FusionIndexProvider(generic, lucene, new FusionSlotSelector30(), DESCRIPTOR, directoriesByProvider(databaseDirectory), fs, archiveFailedIndex, readOnlyChecker);
}
Also used : GenericNativeIndexProvider(org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider) DatabaseIndexContext(org.neo4j.kernel.impl.index.schema.DatabaseIndexContext) IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) LuceneIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneIndexProvider) VisibleForTesting(org.neo4j.util.VisibleForTesting)

Aggregations

LuceneIndexProvider (org.neo4j.kernel.api.impl.schema.LuceneIndexProvider)3 Test (org.junit.jupiter.api.Test)1 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)1 IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)1 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)1 IndexSamplingJob (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingJob)1 DatabaseIndexContext (org.neo4j.kernel.impl.index.schema.DatabaseIndexContext)1 GenericNativeIndexProvider (org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider)1 FusionIndexProvider (org.neo4j.kernel.impl.index.schema.fusion.FusionIndexProvider)1 Monitors (org.neo4j.monitoring.Monitors)1 VisibleForTesting (org.neo4j.util.VisibleForTesting)1