Forcing an IndexReader to read-only

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Forcing an IndexReader to read-only

Fredrik Andersson-2-2
Hi guys!

I don't know if I've missed some crucial feature here, but how d'you
actually force an IndexSearcher (and hence, the underlying IndexReader) to
go read-only? The default behaviour now seems to be that the first one to
acquire a lock automatically gets a read/write-lock, instead of leaving that
optional. What's the deal here?

Thanks,
Fredrik
Reply | Threaded
Open this post in threaded view
|

Re: Forcing an IndexReader to read-only

Chris Hostetter-3

IndexReaders are "read only" by default ... they obtain a lock on teh
index very breifly when they are open to ensure that they get a consistent
view of the index, but that lock is then released and the IndexReader ha
no further need to lock the index unless you attempt a delete.

: Date: Wed, 30 Aug 2006 17:31:32 +0200
: From: Fredrik Andersson <[hidden email]>
: Reply-To: [hidden email]
: To: [hidden email]
: Subject: Forcing an IndexReader to read-only
:
: Hi guys!
:
: I don't know if I've missed some crucial feature here, but how d'you
: actually force an IndexSearcher (and hence, the underlying IndexReader) to
: go read-only? The default behaviour now seems to be that the first one to
: acquire a lock automatically gets a read/write-lock, instead of leaving that
: optional. What's the deal here?
:
: Thanks,
: Fredrik
:



-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: Forcing an IndexReader to read-only

Fredrik Andersson-2-2
Even if it's very briefly whilst opening the index - a writelock is a
writelock. If anyone has any trick to work around these locks (how brief
they may be), I'd really appreciate it. I really can't tolerate any
"mishaps" in this system with regards to index locks. I think I've
previously worked around this by catching the locked exception (whatever it
throws) and trying again, until it succeeds, but that doesn't feel right for
a classy coder.

I think that Lucene is one of the cleanest and nicest API:s ever (have used
it for years!), but with an exception for the IndexReader :)

Fredrik

On 8/30/06, Chris Hostetter <[hidden email]> wrote:

>
>
> IndexReaders are "read only" by default ... they obtain a lock on teh
> index very breifly when they are open to ensure that they get a consistent
> view of the index, but that lock is then released and the IndexReader ha
> no further need to lock the index unless you attempt a delete.
>
> : Date: Wed, 30 Aug 2006 17:31:32 +0200
> : From: Fredrik Andersson <[hidden email]>
> : Reply-To: [hidden email]
> : To: [hidden email]
> : Subject: Forcing an IndexReader to read-only
> :
> : Hi guys!
> :
> : I don't know if I've missed some crucial feature here, but how d'you
> : actually force an IndexSearcher (and hence, the underlying IndexReader)
> to
> : go read-only? The default behaviour now seems to be that the first one
> to
> : acquire a lock automatically gets a read/write-lock, instead of leaving
> that
> : optional. What's the deal here?
> :
> : Thanks,
> : Fredrik
> :
>
>
>
> -Hoss
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Forcing an IndexReader to read-only

Chris Hostetter-3

: Even if it's very briefly whilst opening the index - a writelock is a
: writelock. If anyone has any trick to work around these locks (how brief

I didn't say "writelock" i said "lock" .... specifically it's a "commit
lock" that's used, and if there is any possibility whatsoever that some
other IndexReader or IndexWriter will be attempting to modify the index at
the moment you are opening your IndexReader, that commit lock is
neccessary to ensure that your reader gets a uniform list of the segments.

If you are 100% certain that your indiex can't be modified at any time
(ie: it's on a CD or something like that) you can use the
FSDirectory.setDisableLocks(true) method to tell Lucene not to bother.

-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: Forcing an IndexReader to read-only

Fredrik Andersson-2-2
Hossman, thank you! Exactly what I was looking for. And I know the
application of "locks", it's just a little peculiar situation right now
which requires this... "fix" : )

Fredrik

On 8/31/06, Chris Hostetter <[hidden email]> wrote:

>
>
> : Even if it's very briefly whilst opening the index - a writelock is a
> : writelock. If anyone has any trick to work around these locks (how brief
>
> I didn't say "writelock" i said "lock" .... specifically it's a "commit
> lock" that's used, and if there is any possibility whatsoever that some
> other IndexReader or IndexWriter will be attempting to modify the index at
> the moment you are opening your IndexReader, that commit lock is
> neccessary to ensure that your reader gets a uniform list of the segments.
>
> If you are 100% certain that your indiex can't be modified at any time
> (ie: it's on a CD or something like that) you can use the
> FSDirectory.setDisableLocks(true) method to tell Lucene not to bother.
>
> -Hoss
>
>