At the moment if an IndexWriter cannot obtain a lock on an AzureDirectory this is typically signaled as a Microsoft.WindowsAzure.Storage.StorageException. Class AzureLock passes this through as-is, in other words AzureLock.Obtain() will pass on StorageException to the caller.
However, the implementation of Obtain(long lockWaitTimeout) in base class Lock does not expect an exception to be thrown by the implementation of the abstract and parameter less method Lock.Obtain(). Obtain(long lockWaitTimeout) expects a boolean from Obtain() indicating if the lock was successfully obtained. If the return value is false, then Lock.Obtain(long lockWaitTimeout) will throw an exception of type LockObtainFailedException.
The implementation of AzureLock should not pass on StorageException when a lock cannot be obtained. Instead it should return false to the caller, ie Lock.Obtain(long lockWaitTimeout). The caller would then be able to behave exactly the same as if a Directory other than AzureDirectory was used, e.g. SimpleFSDirectory.
This could potentially be implemented by checking the HttpStatusCode for 412 in method AzureLock._handleException(...) or alternatively in the catch-block of method AzureLock.Obtain().
This code could potentially be used as a test when run inside of Parallel.ForEach() with MaxDegreeOfParallelism set to at least 2.
At the moment if an IndexWriter cannot obtain a lock on an AzureDirectory this is typically signaled as a Microsoft.WindowsAzure.Storage.StorageException. Class AzureLock passes this through as-is, in other words AzureLock.Obtain() will pass on StorageException to the caller.
However, the implementation of Obtain(long lockWaitTimeout) in base class Lock does not expect an exception to be thrown by the implementation of the abstract and parameter less method Lock.Obtain(). Obtain(long lockWaitTimeout) expects a boolean from Obtain() indicating if the lock was successfully obtained. If the return value is false, then Lock.Obtain(long lockWaitTimeout) will throw an exception of type LockObtainFailedException.
The implementation of AzureLock should not pass on StorageException when a lock cannot be obtained. Instead it should return false to the caller, ie Lock.Obtain(long lockWaitTimeout). The caller would then be able to behave exactly the same as if a Directory other than AzureDirectory was used, e.g. SimpleFSDirectory.
This could potentially be implemented by checking the HttpStatusCode for 412 in method AzureLock._handleException(...) or alternatively in the catch-block of method AzureLock.Obtain().
This code could potentially be used as a test when run inside of Parallel.ForEach() with MaxDegreeOfParallelism set to at least 2.