1

For some reason when I delete a document from a Lucene index it is throwing a "no segments* file found in AzureDirectory" exception. This only happens when trying to load the data stored remotely in Azure blob storage. The local index updates fine and continues to operate until the local copy get cleared. Then when the issue present when it tries to load the index from remote Azure blob storage then the error presents. I am able to duplicate this by making a modification to the index, deleting the local index immediately, then to reread the index so that it has to download from blob storage again. There are files in both the local and remote paths after this method runs.

Secondarily, I am also having an issue where it seems the write locks on local temp files do not release with out me having to make an explicit call to the garbage collector.

If anyone has any insight as to what I am doing wrong I would greatly appreciate it.

Dependencies:

.Net Core 5.0
Lucene.Net 4.8.0-beta0016
Lucene.Net.QueryParser 4.8.0-beta16
Lucene.Net.Store.Azure 4.8.0-beta15

I tried reverting Lucene.Net and Lucene.Net.QueryParser to 4.8.0-beta15 to match Lucene.Net.Store.Azure but the results are still the same.

private void IndexDocument(List<MyModel> toDelete)
{
    string connectionString = "My connection string info.";
    string remotePath = "my/remote/path";
    List<string> excludes = toDelete.Select(o => o.Id).ToList();
    string localPath = @"C:\my\local\path\";
    AzureDirectory folder = new AzureDirectory(connectionString, remotePath, FSDirectory.Open(localPath)); 
    StandardAnalyzer analyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);
    IndexWriterConfig config = new IndexWriterConfig(LuceneVersion.LUCENE_48, analyzer);
    IndexWriter writer = new IndexWriter(folder, config); // Create writer
    
    foreach (var exclude in excludes)
    {
        Term term = new Term("MyId", exclude);
        writer.DeleteDocuments(term);
    }
    
    writer.Commit();
    folder.ClearLock("write.lock");
    writer.Dispose();
    folder.Dispose();
    
    // The locks on the local files do not get released until garbage collector is called.
    // https://stackoverflow.com/questions/13262548/delete-a-file-being-used-by-another-process
    GC.Collect();
    GC.WaitForPendingFinalizers();
}
  • This may have something to do with the fact that they are [still targeting Lucene.Net 4.8.0-beta00015](https://github.com/tomlm/Lucene.Net.Store.Azure/blob/b3e794dd4ad831a2f9efa30ade07afcbbb95434a/source/Lucene.Net.Store.Azure/Lucene.Net.Store.Azure.csproj#L31). There are some [breaking API and segment filename changes in 4.8.0-beta00016](https://github.com/apache/lucenenet/releases/tag/Lucene.Net_4_8_0_beta00016) that might not be compatible. Have you tried using 4.8.0-beta00015? – NightOwl888 Apr 02 '22 at 14:01
  • Yes, I tried beta0015 but got the same result. – Michael Halpin Apr 04 '22 at 14:16
  • I don't know if this helps, but there are 2 other Azure Directory implementations I am aware of [Lucene.Net.Store.AzureBlob](https://gitlab.com/rokeller/lucene.net.store.azureblob/-/tree/1-beta/) and [AzureDirectory](https://github.com/azure-contrib/AzureDirectory). Both are targeting 4.8.0, but are based on earlier betas and will probably need a recompile to work with beta-00016. – NightOwl888 Apr 04 '22 at 15:21

0 Answers0