Mailing List Archive

problems with last patch (obtain write.lock while deleting documents)
Hi,

I've just updated my version (via CVS) and now I'm having problems with document deletion. I'm trying to delete a document using
IndexReader's delete(Term) method and I'm getting an IOException:

java.io.IOException: Index locked for write: Lock@E:\temp\index\write.lock
at org.apache.lucene.index.IndexReader.delete(Unknown Source)
at org.apache.lucene.index.SegmentsReader.doDelete(Unknown Source)
at org.apache.lucene.index.IndexReader.delete(Unknown Source)
at org.apache.lucene.index.IndexReader.delete(Unknown Source)
(...)

I'm doing:
IndexReader reader = IndexReader.open("index");
reader.delete(new Term("fileid", id));
reader.close();

I've taken a look at the sources but couldn't find anything wrong. Any ideas?

TIA

Regards,

--Daniel


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: problems with last patch (obtain write.lock while deleting documents) [ In reply to ]
Hi Doug,

Problem solved, thanks!

BTW, is the way I'm doing the deletion the correct one? I reckon I can't use a cached reader, since I have to close it after the
deletion to release the write lock. Does it make sense? Regarding writers, is it ok to share a single IndexWriter with multiple
writers, i.e., I have one writer adding a document and then I get another request for doc upload. I can't open a new IndexWriter
because of the write lock, so I'm using the one already available. After all writers are done, the IndexWriter is closed.

Again, thanks a lot (for the fix and, most important, for Lucene)

--Daniel

> -----Original Message-----
> From: Doug Cutting [mailto:DCutting@grandcentral.com]
> Sent: domingo, 10 de fevereiro de 2002 19:55
> To: 'Lucene Users List'
> Subject: RE: problems with last patch (obtain write.lock while deleting
> documents)
>
>
> > From: Daniel Calvo [mailto:dcalvo@ig.com.br]
> >
> > I've just updated my version (via CVS) and now I'm having
> > problems with document deletion. I'm trying to delete a document using
> > IndexReader's delete(Term) method and I'm getting an IOException:
> >
> > java.io.IOException: Index locked for write:
>
> Oops. I think I see the problem. I only tested this on an optimized index!
>
> I just checked in a fix. Try it and tell me how it goes.
>
> Sorry for the inconvenience,
>
> Doug
>
> --
> To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: problems with last patch (obtain write.lock while deleting documents) [ In reply to ]
> From: Doug Cutting [mailto:DCutting@grandcentral.com]

> It is most effiecient to batch deletions and insertions, i.e., perform a
> bunch of deletions on a single IndexReader, close it, then perform a bunch
> of insertions on a single IndexWriter. Usually the IndexReader that you do
> the deletions on is different than the one other threads are simultaneously
> using for searching, since if you close a reader while a search is underway
> it will crash the search.

Unfortunately I can't do that in my application. Users are allowed to insert and delete files at any time and changes should be
reflected asap.

Thanks for the answer,

--Daniel


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>