I am using Lucene.net 3.0.3 and AzureDirectory 2.0.4937.26631, which I installed from NuGet (Lucene.Net.Store.Azure on NuGet).
The description of the azuredirectory.codeplex.com project reads: "To be more specific: you can have 1..N job roles adding documents to the index and 1..N web searches in the catalog in near real time." (in italics). Suppose that it is possible to write multiple work roles in an index simultaneously. However, when I try to do this, I get a lot of "Lock commit: AzureLock@write.lock " results. exceptions.
My code follows the example given in the AzureDirectory documentation ( azuredirectory.codeplex.com/documentation ). My code is approximately (simplified for the question).
var dbEntities =
When run sequentially, this code works fine. However, if I run the same code in parallel on multiple threads / workers. I get a lot of "Lock commit: AzureLock@write.lock " results. Exceptions:
[Lucene.Net.Store.LockObtainFailedException: Lock obtain timed out: AzureLock@write.lock. ] at Lucene.Net.Store.Lock.Obtain(Int64 lockWaitTimeout) in d:\Lucene.Net\FullRepo\trunk\src\core\Store\Lock.cs:line 83 at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean create, IndexDeletionPolicy deletionPolicy, Int32 maxFieldLength, IndexingChain indexingChain, IndexCommit commit) in d:\Lucene.Net\FullRepo\trunk\src\core\Index\IndexWriter.cs:line 1228 at Lucene.Net.Index.IndexWriter..ctor(Directory d, Analyzer a, Boolean create, MaxFieldLength mfl) in d:\Lucene.Net\FullRepo\trunk\src\core\Index\IndexWriter.cs:line 1018
I understand that the file "write.lock" is created in the blob repository, and when the file contains the text "written.lock", the lock is saved. According to my observations, users had problems with the fact that write.lock is not cleared. This does not seem like my problem, since I can get the same code to work correctly when it is executed sequentially, and the lock file is cleared in this case.
I see in the AzureDirectory documentation ( azuredirectory.codeplex.com/documentation ): "An index can only be updated by one process at a time, so it makes sense to push all the Add / Update / Delete operations using the indexing role." However, this does not make any sense, since any role you create must have several instances, therefore, in parallel with several instances that will be written to the index. In addition, the project description explicitly states that "you may have 1..N working roles adding documents to the index ". Note that this speaks of an“ index, ”not a fragment of the index.
Question:
So, is the project description just wrong? Or is there some way to have multiple indexers adding parallel index? I do not see anything in the API to allow this. If possible, provide a code snippet on how to use AzureDirectory to "have 1..N working role roles by adding documents to the index."