Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StorageException with HttpStatusCode 412 should translate to LockObtainFailedException #28

Open
ManfredLange opened this issue Nov 21, 2017 · 0 comments

Comments

@ManfredLange
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant