lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Vanlerberghe (JIRA)" <>
Subject [jira] Updated: (LUCENE-481) IndexReader.getCurrentVersion() and isCurrent should use commit lock.
Date Thu, 22 Dec 2005 16:37:31 GMT
     [ ]

Luc Vanlerberghe updated LUCENE-481:

    Attachment: LUCENE-481.patch

This should fix the problem.

I didn't use the Lock.With helper class to avoid having to wrap the long or boolean result
in a Long or Boolean first.
The try ... finally block should be at least as clear to read as the Lock.With construct in
this case...

The problem is not limited to Windows Platforms:
The search servers also threw " ...\segments (The system cannot
find the file specified)" once every few days....

This is because the new segments data is first written to the file "" which is
then renamed to "segments".
The javadoc for Directory says renameTo() should be atomic, but the current implementation
in FSDirectory isn't.
If the searcher happens to try to read the segments file in the (admittedly very small) time
between the "nu.delete()" and the "old.renameTo(nu)" it gets the FileNotFoundException

> IndexReader.getCurrentVersion() and isCurrent should use commit lock.
> ---------------------------------------------------------------------
>          Key: LUCENE-481
>          URL:
>      Project: Lucene - Java
>         Type: Bug
>   Components: Index
>     Versions: CVS Nightly - Specify date in submission
>  Environment: Windows platform, all Lucene versions
>     Reporter: Luc Vanlerberghe
>  Attachments: LUCENE-481.patch
> There is a race condition if one machine is checking the current version of an index
while another wants to update the segments file in IndexWriter.close().
> Cannot delete segments
> 	at
> 	at org.apache.lucene.index.SegmentInfos.write(
> 	at org.apache.lucene.index.IndexWriter$3.doBody(
> 	at$
> 	at org.apache.lucene.index.IndexWriter.mergeSegments(
> 	at org.apache.lucene.index.IndexWriter.flushRamSegments(
> 	at org.apache.lucene.index.IndexWriter.close(
> On the windows platform reading the contents of a file disallows deleting the file.
> I use Lucene to maintain an index of +-700.000 documents, one server adds documents,
while other servers handle the searches.
> The search servers poll the index version regularly to check if they have to reopen their
> Once in a while (about once every two days on average), IndexWriter.close() fails because
it cannot delete the previous segments file, even though it hold the commit lock.
> The reason is probably that search servers are reading the segments file to check the
version without using the commit lock.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message