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
}
}
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());
}
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);
}
Aggregations