/// <summary> /// This test come from a support case where dropping an index would block forever after index sampling failed. /// <para> /// A fusion index has multiple <seealso cref="IndexSampler index samplers"/> that are called sequentially. If one fails, then the other will never be invoked. /// This was a problem for <seealso cref="LuceneIndexSampler"/>. It owns a <seealso cref="org.neo4j.helpers.TaskControl"/> that it will try to release in try-finally /// in <seealso cref="LuceneIndexSampler.sampleIndex()"/>. But it never gets here because a prior <seealso cref="IndexSampler"/> fails. /// </para> /// <para> /// Because the <seealso cref="org.neo4j.helpers.TaskControl"/> was never released the lucene accessor would block forever, waiting for /// <seealso cref="TaskCoordinator.awaitCompletion()"/>. /// </para> /// <para> /// This situation was solved by making <seealso cref="IndexSampler"/> <seealso cref="System.IDisposable"/> and include it in try-with-resource together with /// <seealso cref="IndexReader"/> that created it. /// </para> /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 5_000L) public void failedIndexSamplingMustNotPreventIndexDrop() throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void FailedIndexSamplingMustNotPreventIndexDrop() { LuceneIndexProvider luceneProvider = luceneProvider(); MakeSureIndexHasSomeData(luceneProvider); // Otherwise no sampler will be created. IndexProvider failingProvider = failingProvider(); FusionIndexProvider fusionProvider = CreateFusionProvider(luceneProvider, failingProvider); using (IndexAccessor fusionAccessor = fusionProvider.GetOnlineAccessor(_storeIndexDescriptor, _samplingConfig)) { IndexSamplingJob indexSamplingJob = CreateIndexSamplingJob(fusionAccessor); // Call run from other thread try { indexSamplingJob.run(); } catch (Exception e) { assertSame(e, _sampleException); } // then fusionAccessor.Drop(); // should not block forever } }