lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Wilde" <rich...@wildesoft.net>
Subject File locking
Date Fri, 05 Apr 2013 10:19:22 GMT
I have deployed my application on Rackspace cloud (have 3-4 nodes running
iis all sharing the same files) and am running into issues with:-

 

The process cannot access the file
'\\fs1-n01\stor1wc1dfw1\381858\799525\somedomain.com\web\content\App_Data\Lu
ceneIndex\write.lock' because it is being used by another process.

 

I am not sure why I am running into this issue, the code for this error is:-

 

public void Delete(long id, string type)

{

         directory = FSDirectory.Open(new
DirectoryInfo(Settings.LuceneBaseDir));

         var writer = new IndexWriter(directory, analyzer, false,
IndexWriter.MaxFieldLength.LIMITED);

         var queryParser = new QueryParser(Version.LUCENE_29, "Extract",
analyzer);

         var special = string.Format("Id:{0} AND Type:{1}", id, type);

         writer.DeleteDocuments(queryParser.Parse(special));

         writer.Commit();

         writer.Close();

         directory.Close();

}

 

I have also code that indexes like:-

 

        public void Index(Document document)

        {

            directory = FSDirectory.Open(new
DirectoryInfo(Settings.LuceneBaseDir));

            var writer = new IndexWriter(directory, analyzer, false,
IndexWriter.MaxFieldLength.LIMITED);

            writer.AddDocument(document);

            writer.Close();

            directory.Close();

        }

 

      public void Index(Contact entity)

      {

         indexer.Index(GetDocument(entity));

      }

 

public Document GetDocument(Contact entity)

{

    var mytext = entity.ToStringExtension();

    var doc = new Document();

    doc.Add(new Field(IndexColumns.Extract.ToString(), mytext,
Field.Store.YES, Field.Index.ANALYZED));

    doc.Add(new Field(IndexColumns.Type.ToString(), DocumentType,
Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));

    doc.Add(new Field(IndexColumns.ClientId.ToString(),
entity.Client.Id.ToString(), Field.Store.YES,
Field.Index.ANALYZED_NO_NORMS));

    doc.Add(new Field(IndexColumns.Title.ToString(), entity.Firstname + " "
+ entity.Lastname, Field.Store.YES, Field.Index.NOT_ANALYZED));

    doc.Add(new Field(IndexColumns.Content.ToString(), entity.Company,
Field.Store.YES, Field.Index.NOT_ANALYZED));

    doc.Add(new Field(IndexColumns.Misc1.ToString(), entity.Phone,
Field.Store.YES, Field.Index.NOT_ANALYZED));

    doc.Add(new Field(IndexColumns.Misc2.ToString(),
entity.Email.ToString(CultureInfo.InvariantCulture), Field.Store.YES,
Field.Index.NOT_ANALYZED));

    doc.Add(new Field(IndexColumns.Category.ToString(), entity.Category,
Field.Store.YES, Field.Index.NOT_ANALYZED));

    doc.Add(new Field(IndexColumns.Id.ToString(),
entity.Id.ToString(CultureInfo.InvariantCulture), Field.Store.YES,
Field.Index.NOT_ANALYZED));

    return doc;

}

 

 

The error is intermittent but seems to happen when I delete/insert a
document. I have a background service (web based) that may also be writing
documents to the index every 30 seconds or so.. 

I am on version 2.9.4.2, should I upgrade to 3.0.3 bearing in mind I am
running in Partial Trust and I recall reading an email regarding some
problems with the release (I might be mistaken)

 

I suspect I am doing something stupid not sure how I can diagnose the
problem?

 

Thanks

Rippo

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message