Lucene.net create+lock errors in ASP.NET
- by acidzombie24
I have an issue with Lucene.net. It throws a lock exception. After poking around i notice these things.
My code below works in an app bit when calling in Application_Start i get a NoSuchDirectoryException.
Not closing the writer (as my code doesnt do below) i WILL get a LockObtainFailedException with the message
Lock obtain timed out: SimpleFSLock@<FULL_PATH> from either app or asp.net
These thread hinted when spawning threads they get less permissions then i do (but! my main thread has problems as well...) and one solution is to impersonate IIS. I am using visual studios 2010. I am not sure how full blown it is but my attempt to impersonate it failed.
So my question is how do i have lucene create the directory and not throw an exception if dont close the writer for some reason (such as power going out)?
http://stackoverflow.com/questions/2341163/why-is-my-lucene-index-getting-locked/2499285#2499285
http://stackoverflow.com/questions/1123517/lucene-net-and-i-o-threading-issue/1123981#1123981
static IndexWriter writer = null;
static void lucene_init()
{
bool create = false;
string dirname = "LuceneIndex_z";
if (System.IO.Directory.Exists(dirname) == false)
create = true;
var directory = FSDirectory.GetDirectory(dirname);
var analyzer = new StandardAnalyzer();
writer = new IndexWriter(directory, analyzer, create);
}