azure-contrib / AzureDirectory

A Lucene Directory Provider for Azure Blob Storage
Microsoft Public License
77 stars 57 forks source link

_name is always null when calling GrabMutex in AzureIndexOutput #19

Closed Shazwazza closed 4 years ago

Shazwazza commented 8 years ago

This seems a bit odd but maybe it's by design but in the ctor of AzureIndexOutput the first line is:

_fileMutex = BlobMutexManager.GrabMutex(_name); 

but the _name will always be null in this case because it hasn't been initialized yet. Is this intended?

yohsii commented 4 years ago

@Shazwazza hi did you amend this in your examine with azure directory code? does seem odd and i'm tempted to fix it as i doubt it's intended.

Shazwazza commented 4 years ago

@yohsii Hi! yeah i've more or less overhauled the whole thing in my examine project. This _name should definitely not be null. I've found that trying to use a "native" blob storage lease for the lock was causing some issues and that just using a simple file based lock was more resilient (ironically).

You can find my latest code here: https://github.com/Shazwazza/Examine/tree/master/src/Examine.AzureDirectory

There's other features in there like ReadOnlyAzureDirectoryFactory in cases where you might have multiple servers asking for the index - but of course you cannot have multiple servers writing to the index, so this would work for readonly front-end servers while you would have a 'master' read/write server responsible for writing to the index.

There's a lot of other stuff fixed up in the AzureDirectory.cs main class. Feel free to copy/re-use/backport/etc... I had a note in a commit to backport these changes here but I never got around to it unfortunatley.

yohsii commented 4 years ago

Cheers Shazwazza, I've included the _name fix in my pr which updates the project for .net standard 2.0 lucene 4.8 and latest azure blob library

yohsii commented 4 years ago

i've also created SyncDirectory which offers another strategy for using Lucene.Net with Azure.