سؤال

We implemented Lucene.NET to handle the search of hashtags in our server. The implementation was made in a Windows Azure Worker Role.

We based ourselves on the example provided by Leon Cullens in his blog, which you can see here. The indexer writes the indexed documents to Windows Azure Storage.

When we publish it to Windows Azure, the first time the indexer is created everything is fine, but we don't get our indexer updated after that.

When we test this locally, the Thread sleeps and wakes up normally the first time, but sometimes the second time it throws an Exception:

An unhandled exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.WindowsAzure.Storage.dll

Additional information: The remote server returned an error: (412) 
There is currently a lease on the blob and no lease ID was specified in the request..

From what we can guess, this happens when the storage is being overwritten. Do we require to specify something else?

We had a previous problem when publishing to Azure, the indexer could not be created because we were required to specify a RAMDirectory object. We changed the code to look like this:

Microsoft.WindowsAzure.Storage.CloudStorageAccount cloudStorageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.DevelopmentStorageAccount;
                Microsoft.WindowsAzure.Storage.CloudStorageAccount.TryParse(CloudConfigurationManager.GetSetting("ConnectionStringAzureSearch"), out cloudStorageAccount);

AzureDirectory azureDirectoryExample = new AzureDirectory(cloudStorageAccount, "indexsearch", new Lucene.Net.Store.RAMDirectory());

Could this be related? From the 412 response code, we can only guess something "goes missing" when trying to recreate the indexer.

Could it be we need to call a sort of update function since recreating the indexer might be a wrong approach?

هل كانت مفيدة؟

المحلول

We found our problem.

In our worker role we have an instance of our Indexer class being created outside our while loop.

Not only this made the indexer to not update with the new entries, but somehow it caused the worker role to crash. Maybe the references were pointing somewhere that didn't exist anymore when we deleted the old entries in our storage.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top