Issue Details (XML | Word | Printable)

Key: LUCENE-425
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Mikko Noromaa
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

"Cannot rename segments.new to segments"

Created: 18/Aug/05 09:26 PM   Updated: 16/Nov/07 02:44 PM
Return to search
Component/s: Index
Affects Version/s: 1.4
Fix Version/s: None

Time Tracking:
Not Specified

Environment:
Operating System: Windows XP
Platform: PC

Bugzilla Id: 36241
Resolution Date: 10/Nov/06 11:24 AM


 Description  « Hide
AddDocument periodically fails with "Cannot rename segments.new to segments".
Sometimes it happens after 10,000 documents, sometimes after 200,000 documents.

My index is placed on a FAT partition. My Lucene version is 1.4.3. I am using
a single IndexWriter object and doing all AddDocuments calls serially from a
single thread.

I saw some discussion about this problem in the mailing lists, but looks like
the problem wasn't completely eliminated yet.

My suggested solutions are as follows:

  • If renameTo() fails, wait some time and retry. After this, apply the other
    methods that are now in FSDirectory.java. Retry them as well after waiting for
    some time.
  • In the IndexWriter constructor, check for 'segments.new' if 'segments'
    cannot be found. This would allow recovery if FSDirectory failed on a previous
    run. Now I have to write the recovery code myself outside of Lucene.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jeff Turner made changes - 03/Sep/05 03:30 PM
Field Original Value New Value
issue.field.bugzillaimportkey 36241 12314575
Michael McCandless added a comment - 09/Aug/06 01:00 PM

There was a recent thread on java-user that looks very similar to this issue:

http://www.gossamer-threads.com/lists/lucene/java-user/38669

When Lucene writes a new "segments" or new "deletable" file it first
writes to X.new and then renames X.new --> X. Apparently that
renameTo can sometimes fail, even though both the X.new and the X file
are "closed" from Java.

The "best guess" from that discussion is that there is a JVM bug on
certain JVMs on Windows, whereby a file handle (at the Windows OS
level) is held open even after from Java it has been "closed".

Ant has a workaround for this issue: force a GC, wait, and then retry.
I don't really like that workaround for Lucene because we should not
suddenly / unexpectedly do a system level action like forcing GC –
it's a "leaky abstraction"
(http://www.joelonsoftware.com/articles/LeakyAbstractions.html).

Which JVM are you using? I couldn't reproduce this; I made a small
change to the IndexFiles demo command-line tool and then refreshed the
view from Windows Explorer. On Sun JDK 1.4.2_10 and Sun JDK 1.5.0_07
I couldn't get the IOException.

Issue LUCNE-554 also proposes more robust logic around opening the
.NEW file if it exists. I think that makes alot of sense.


Michael McCandless added a comment - 10/Nov/06 11:24 AM

I think this one is a dup of LUCENE-665

The intermittant errors on WIN32 came down to 3rd party software that can open files shortly after they were created, thus preventing rename from succeeding. The combination of native LockFactor implementation (LUCENE-678 ) and Lockless commits (LUCENE-701 ) should resolve these issues.


Michael McCandless made changes - 10/Nov/06 11:24 AM
Status Open [ 1 ] Closed [ 6 ]
Assignee Lucene Developers [ java-dev@lucene.apache.org ]
Resolution Duplicate [ 3 ]
Chris Bowditch added a comment - 16/Nov/07 02:09 PM - edited
We have been using Lucene 1.9.1 for the past 2 years and this issue occurs on a regular basis. Always on Windows and more often on machines with slower hard disks, i.e. Laptops. A colleague of mine downloaded the source and patched it to retry the rename and delete operations several times before giving up. This works well on our environments so we would like to get the change into Trunk code.

I will prepare a patch against trunk shortly which will solve the problem.


Michael McCandless added a comment - 16/Nov/07 02:44 PM
I believe the root cause of this issue was resolved with LUCENE-701: we no longer rename files when writing a Lucene index.

Are you able to get this issue to happen with Lucene 2.2?