Why is my Lucene index blocked?

I had a problem with my search but did not return the expected results.

I tried to run Luke at my index, but he said it was locked and I needed to get it to unlock (I'm not a Jedi / Sith).

I tried to delete the index folder and run the recreate-indicies application, but the folder was locked. Using unlocker, I found that there are about 100 w3wp.exe entries (the same PID, another Handle) with an index lock.

What's happening?

I do 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 where I request 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>(); 

What's happening? What am I doing wrong?

thanks

+4
source share
3 answers

Index Lucene.Net blocks simultaneous write operations on an index. You can have as many threads as you like in searching / reading from the index, and they won’t block - either with each other or with someone who writes, however, if you have two threads writing to the index at the same time, there is a chance that one of them will be blocked on the other.

If lucene tells you that your index is locked, it means that either someone is currently writing the index, or (this sounds more likely) what was written by the index was killed during recording, and therefore the lock could not be removed You must make sure that you correctly dispose of any Lucene objects that are written to the index as soon as they are executed.

To remove the lock manually, there is a .lock file that needs to be deleted in the Lucene directory (my big Lucene book is not near me right now, so I don’t know exactly where it is, but search for β€œlock” or β€œ.lock” in the Lucene directory should find him)

The pens w3wp.exe had in this directory were probably pens belonging to the streams read from the lucene index β€” although they would not allow you to delete the directory, they should not stop you from searching or writing to the index.

+4
source

Delete the file "write.lock" in the index folder.

+1
source

Source: https://habr.com/ru/post/1302475/


All Articles