You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Robert Pohl <ro...@gmail.com> on 2011/09/01 10:30:14 UTC

[Lucene.Net] Locked File while adding doc to writer

Hi,

Suddenly i cannot add doc to the index (Lucene.Net 2.0.0.4), i get this 
exception:

"{"Cannot rename 
C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new to 
C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deletable"}"

Inner exception: "{"The process cannot access the file 
'C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new' because it 
is being used by another process."}"

 From my Google'ing this seems like a Windows locking problem.
I turned of system indexing in win, but it didn't help.

Do you guys know of a workaround?

My Code:
IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
...

var doc = new Document();
doc.Add(new Lucene.Net.Documents.Field("Id", p.Id.ToString(), 
Field.Store.YES, Field.Index.UN_TOKENIZED));
doc.Add(new Field("ISBN", p.ExternalId, Field.Store.YES, 
Field.Index.TOKENIZED));
doc.Add(new Field("Title", p.ProductName, Field.Store.YES, 
Field.Index.TOKENIZED));
doc.Add(new Field("Category", catName, Field.Store.YES, 
Field.Index.TOKENIZED));
doc.Add(new Field("Contributors", p.GetContributors(false), 
Field.Store.YES, Field.Index.TOKENIZED));
doc.Add(new Field("BookType", p.BookType(), Field.Store.YES, 
Field.Index.UN_TOKENIZED));
doc.Add(new Field("Description", p.DescriptionLong, Field.Store.YES, 
Field.Index.TOKENIZED));

writer.AddDocument(doc); <-- error is here after a while

Thanks,
Robert


RE: [Lucene.Net] Locked File while adding doc to writer

Posted by Digy <di...@gmail.com>.
Even if it were OS/Windows thing, Lucene.Net should be able to handle that
kind of problems. 
Can you send a *small* test case?

DIGY

-----Original Message-----
From: Robert Pohl [mailto:robban.p@gmail.com] 
Sent: Friday, September 02, 2011 10:52 AM
To: lucene-net-user@lucene.apache.org
Subject: Re: [Lucene.Net] Locked File while adding doc to writer

Hi, the new version did not fix the problem :/

I've seen some hacks in the Java version where they do retry functions 
which seems a bit nasty.
Is this a OS/WIndows thing or a Lucene.Net issue?
Any ideas?

Thanks,
Robert


On 2011/09/01/ 7:43 PM, Digy wrote:
> Try a newer version of Lucene.Net.
> http://incubator.apache.org/lucene.net/download.html
>
> DIGY
>
> -----Original Message-----
> From: Robert Pohl [mailto:robban.p@gmail.com]
> Sent: Thursday, September 01, 2011 11:30 AM
> To: lucene-net-user@lucene.apache.org
> Subject: [Lucene.Net] Locked File while adding doc to writer
>
> Hi,
>
> Suddenly i cannot add doc to the index (Lucene.Net 2.0.0.4), i get this
> exception:
>
> "{"Cannot rename
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new to
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deletable"}"
>
> Inner exception: "{"The process cannot access the file
> 'C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new' because it
> is being used by another process."}"
>
>   From my Google'ing this seems like a Windows locking problem.
> I turned of system indexing in win, but it didn't help.
>
> Do you guys know of a workaround?
>
> My Code:
> IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
> ...
>
> var doc = new Document();
> doc.Add(new Lucene.Net.Documents.Field("Id", p.Id.ToString(),
> Field.Store.YES, Field.Index.UN_TOKENIZED));
> doc.Add(new Field("ISBN", p.ExternalId, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Title", p.ProductName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Category", catName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Contributors", p.GetContributors(false),
> Field.Store.YES, Field.Index.TOKENIZED));
> doc.Add(new Field("BookType", p.BookType(), Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.Add(new Field("Description", p.DescriptionLong, Field.Store.YES,
> Field.Index.TOKENIZED));
>
> writer.AddDocument(doc);<-- error is here after a while
>
> Thanks,
> Robert
>
>


RE: [Lucene.Net] Locked File while adding doc to writer

Posted by Digy <di...@gmail.com>.
BTW, make sure that no other processes (Virus scanners etc.) access that
directory.
DIGY

-----Original Message-----
From: Robert Pohl [mailto:robban.p@gmail.com] 
Sent: Friday, September 02, 2011 10:52 AM
To: lucene-net-user@lucene.apache.org
Subject: Re: [Lucene.Net] Locked File while adding doc to writer

Hi, the new version did not fix the problem :/

I've seen some hacks in the Java version where they do retry functions 
which seems a bit nasty.
Is this a OS/WIndows thing or a Lucene.Net issue?
Any ideas?

Thanks,
Robert


On 2011/09/01/ 7:43 PM, Digy wrote:
> Try a newer version of Lucene.Net.
> http://incubator.apache.org/lucene.net/download.html
>
> DIGY
>
> -----Original Message-----
> From: Robert Pohl [mailto:robban.p@gmail.com]
> Sent: Thursday, September 01, 2011 11:30 AM
> To: lucene-net-user@lucene.apache.org
> Subject: [Lucene.Net] Locked File while adding doc to writer
>
> Hi,
>
> Suddenly i cannot add doc to the index (Lucene.Net 2.0.0.4), i get this
> exception:
>
> "{"Cannot rename
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new to
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deletable"}"
>
> Inner exception: "{"The process cannot access the file
> 'C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new' because it
> is being used by another process."}"
>
>   From my Google'ing this seems like a Windows locking problem.
> I turned of system indexing in win, but it didn't help.
>
> Do you guys know of a workaround?
>
> My Code:
> IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
> ...
>
> var doc = new Document();
> doc.Add(new Lucene.Net.Documents.Field("Id", p.Id.ToString(),
> Field.Store.YES, Field.Index.UN_TOKENIZED));
> doc.Add(new Field("ISBN", p.ExternalId, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Title", p.ProductName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Category", catName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Contributors", p.GetContributors(false),
> Field.Store.YES, Field.Index.TOKENIZED));
> doc.Add(new Field("BookType", p.BookType(), Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.Add(new Field("Description", p.DescriptionLong, Field.Store.YES,
> Field.Index.TOKENIZED));
>
> writer.AddDocument(doc);<-- error is here after a while
>
> Thanks,
> Robert
>
>


Re: [Lucene.Net] Locked File while adding doc to writer

Posted by Robert Pohl <ro...@gmail.com>.
Hi, the new version did not fix the problem :/

I've seen some hacks in the Java version where they do retry functions 
which seems a bit nasty.
Is this a OS/WIndows thing or a Lucene.Net issue?
Any ideas?

Thanks,
Robert


On 2011/09/01/ 7:43 PM, Digy wrote:
> Try a newer version of Lucene.Net.
> http://incubator.apache.org/lucene.net/download.html
>
> DIGY
>
> -----Original Message-----
> From: Robert Pohl [mailto:robban.p@gmail.com]
> Sent: Thursday, September 01, 2011 11:30 AM
> To: lucene-net-user@lucene.apache.org
> Subject: [Lucene.Net] Locked File while adding doc to writer
>
> Hi,
>
> Suddenly i cannot add doc to the index (Lucene.Net 2.0.0.4), i get this
> exception:
>
> "{"Cannot rename
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new to
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deletable"}"
>
> Inner exception: "{"The process cannot access the file
> 'C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new' because it
> is being used by another process."}"
>
>   From my Google'ing this seems like a Windows locking problem.
> I turned of system indexing in win, but it didn't help.
>
> Do you guys know of a workaround?
>
> My Code:
> IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
> ...
>
> var doc = new Document();
> doc.Add(new Lucene.Net.Documents.Field("Id", p.Id.ToString(),
> Field.Store.YES, Field.Index.UN_TOKENIZED));
> doc.Add(new Field("ISBN", p.ExternalId, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Title", p.ProductName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Category", catName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Contributors", p.GetContributors(false),
> Field.Store.YES, Field.Index.TOKENIZED));
> doc.Add(new Field("BookType", p.BookType(), Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.Add(new Field("Description", p.DescriptionLong, Field.Store.YES,
> Field.Index.TOKENIZED));
>
> writer.AddDocument(doc);<-- error is here after a while
>
> Thanks,
> Robert
>
>


Re: [Lucene.Net] Locked File while adding doc to writer

Posted by Robert Pohl <ro...@gmail.com>.
Thanks Digy, always helpful!

//Robert

On 2011/09/01/ 7:43 PM, Digy wrote:
> Try a newer version of Lucene.Net.
> http://incubator.apache.org/lucene.net/download.html
>
> DIGY
>
> -----Original Message-----
> From: Robert Pohl [mailto:robban.p@gmail.com]
> Sent: Thursday, September 01, 2011 11:30 AM
> To: lucene-net-user@lucene.apache.org
> Subject: [Lucene.Net] Locked File while adding doc to writer
>
> Hi,
>
> Suddenly i cannot add doc to the index (Lucene.Net 2.0.0.4), i get this
> exception:
>
> "{"Cannot rename
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new to
> C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deletable"}"
>
> Inner exception: "{"The process cannot access the file
> 'C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new' because it
> is being used by another process."}"
>
>   From my Google'ing this seems like a Windows locking problem.
> I turned of system indexing in win, but it didn't help.
>
> Do you guys know of a workaround?
>
> My Code:
> IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
> ...
>
> var doc = new Document();
> doc.Add(new Lucene.Net.Documents.Field("Id", p.Id.ToString(),
> Field.Store.YES, Field.Index.UN_TOKENIZED));
> doc.Add(new Field("ISBN", p.ExternalId, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Title", p.ProductName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Category", catName, Field.Store.YES,
> Field.Index.TOKENIZED));
> doc.Add(new Field("Contributors", p.GetContributors(false),
> Field.Store.YES, Field.Index.TOKENIZED));
> doc.Add(new Field("BookType", p.BookType(), Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.Add(new Field("Description", p.DescriptionLong, Field.Store.YES,
> Field.Index.TOKENIZED));
>
> writer.AddDocument(doc);<-- error is here after a while
>
> Thanks,
> Robert
>
>


RE: [Lucene.Net] Locked File while adding doc to writer

Posted by Digy <di...@gmail.com>.
Try a newer version of Lucene.Net.
http://incubator.apache.org/lucene.net/download.html

DIGY

-----Original Message-----
From: Robert Pohl [mailto:robban.p@gmail.com] 
Sent: Thursday, September 01, 2011 11:30 AM
To: lucene-net-user@lucene.apache.org
Subject: [Lucene.Net] Locked File while adding doc to writer

Hi,

Suddenly i cannot add doc to the index (Lucene.Net 2.0.0.4), i get this 
exception:

"{"Cannot rename 
C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new to 
C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deletable"}"

Inner exception: "{"The process cannot access the file 
'C:\\work\\Bokborgen\\Bokborgen\\Index_tmp\\deleteable.new' because it 
is being used by another process."}"

 From my Google'ing this seems like a Windows locking problem.
I turned of system indexing in win, but it didn't help.

Do you guys know of a workaround?

My Code:
IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
...

var doc = new Document();
doc.Add(new Lucene.Net.Documents.Field("Id", p.Id.ToString(), 
Field.Store.YES, Field.Index.UN_TOKENIZED));
doc.Add(new Field("ISBN", p.ExternalId, Field.Store.YES, 
Field.Index.TOKENIZED));
doc.Add(new Field("Title", p.ProductName, Field.Store.YES, 
Field.Index.TOKENIZED));
doc.Add(new Field("Category", catName, Field.Store.YES, 
Field.Index.TOKENIZED));
doc.Add(new Field("Contributors", p.GetContributors(false), 
Field.Store.YES, Field.Index.TOKENIZED));
doc.Add(new Field("BookType", p.BookType(), Field.Store.YES, 
Field.Index.UN_TOKENIZED));
doc.Add(new Field("Description", p.DescriptionLong, Field.Store.YES, 
Field.Index.TOKENIZED));

writer.AddDocument(doc); <-- error is here after a while

Thanks,
Robert