I had an issue with my search not return the results I expect.
I tried to run Luke on my index, but it said it was locked and I needed to Force Unlock it (I'm not a Jedi/Sith though)
I tried to delete the index folder and run my recreate-indicies application but the folder was locked. Using unlocker I've found that there are about 100 entries of w3wp.exe (same PID, different Handle) with a lock on the index.
Whats going on?
I'm doing this in my NHibernate configuration:
c.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener());
c.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener());
c.SetListener(ListenerType.PostDelete, new FullTextIndexEventListener());
And here is the only place i query the index:
var fullTextSession = NHibernate.Search.Search.CreateFullTextSession(this.unitOfWork.Session);
var fullTextQuery = fullTextSession.CreateFullTextQuery(query, typeof (Person));
fullTextQuery.SetMaxResults(100);
return fullTextQuery.List<Person>();
Whats going on? What am i doing wrong?
Thanks
The Lucene.Net index only blocks concurrent write operations on the index. You can have as many threads as you like searching / reading from the index and they wont block - either on each other or on anyone doing a write, however if you have two threads doing a write on the index at the same time then there is a chance that one of them will block on the other.
If lucene tells you your index is locked then this means that either someone is currently writing to the index, or (this sounds more likely) something that was writing to the index was killed during writing and so couldn't remove the lock. You should make sure that you properly dispose of any Lucene objects that write to the index as soon as they are done.
To remove the lock manually there is a .lock file that you need to delete inside the Lucene directory (my big book of Lucene is not near me at the moment, so I don't know exactly where it is, but doing a search for "lock", or ".lock" in the Lucene directory should find it)
The handles that w3wp.exe had on this directory were probably the handles owned by the threads reading from the lucene index - although these will prevent you from deleting the directory, they shouldn't prevent you from searching or writing to the index.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With