You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Ken McCracken (Created) (JIRA)" <ji...@apache.org> on 2011/12/07 21:16:40 UTC

[jira] [Created] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
----------------------------------------------------------------------------------------------------------------------

                 Key: LUCENE-3627
                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
             Project: Lucene - Java
          Issue Type: Bug
         Environment: Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)

            Reporter: Ken McCracken
            Priority: Critical


FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.

I will attempt to attach a Test file demonstrates the issue; place it in your 
src/test/org/apache/lucene/store/
directory and run the unit tests with JUnit4.



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165487#comment-13165487 ] 

Ken McCracken commented on LUCENE-3627:
---------------------------------------

Thank you Mike for cleaning my suggestions up.  I am validating and reviewing currently...

What is the svn revision branch this patch would get checked in to?
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Shane Detsch (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165228#comment-13165228 ] 

Shane Detsch commented on LUCENE-3627:
--------------------------------------

Would you ever have the case there only one "segements_N" file is corrupt 'i.e. 0 size'? If so how would another "segments_N" file be regenerated?  Does this 0-sized "segments_N" file always happen on a newly generated "segmetns_N" and "segments_N-1" still exist and is considered active?  After deletion of the 0-sized "segments_N" file is there a process to make sure that the currently active "segmetns_N" (not the 0-sized one) accurately represents the segments in the index?
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Updated] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ken McCracken updated LUCENE-3627:
----------------------------------

          Environment: 
lucene-3.5.0, src download from GA release lucene.apache.org.
Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)


  was:
Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)


    Affects Version/s: 3.5
    
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Priority: Critical
>         Attachments: TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> I will attempt to attach a Test file demonstrates the issue; place it in your 
> src/test/org/apache/lucene/store/
> directory and run the unit tests with JUnit4.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Assigned] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Michael McCandless (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless reassigned LUCENE-3627:
------------------------------------------

    Assignee: Michael McCandless
    
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>         Attachments: LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165560#comment-13165560 ] 

Ken McCracken commented on LUCENE-3627:
---------------------------------------

@Mike:  My initial validation confirms your suggested patch works for me.  Thank you.
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>             Fix For: 3.6, 4.0
>
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Michael McCandless (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165461#comment-13165461 ] 

Michael McCandless commented on LUCENE-3627:
--------------------------------------------


bq. Would you ever have the case there only one "segements_N" file is corrupt 'i.e. 0 size'?

No, unless something terrible is going on, such as your IO system
disregards fsync, you have hardware problems, or something external is
mucking with the index files.

When Lucene commits it writes the next segments_N, fsyncs it (and all
index file it references) and then removes old commits; so the old
commits are not removed until the new one is on durable storage.

I think the conditions for this bug to occur are very rare, ie, lucene
tried to commit, hit a transient IO problem in creating the file (so
that a 0 byte file is created), your app caught this and called
IW.close, this time the transient IO problem is gone and the close
succeeds in writing another segments_N file.  At that point you'd hit
this bug when you next tried to open an IndexWriter on the index.

The more common failure would be if the segments_N fails to write (0
byte file) and then when you close the IW it also fails, ie, because
something suddenly is wrong w/ your IO system.  In this case your
"latest" segments_N is unreadable, and Lucene handles that fine (falls
back to segments_(N-1), which should be ok because it was fsync'd).

                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Michael McCandless (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13166432#comment-13166432 ] 

Michael McCandless commented on LUCENE-3627:
--------------------------------------------

Awesome, thanks Ken!
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>             Fix For: 3.6, 4.0
>
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Updated] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ken McCracken updated LUCENE-3627:
----------------------------------

    Attachment: LUCENE-3627_initial_proposal.txt

Initial proposed patch.  I'm not sure if this is the correct place and scope.  But it does fix my test case.
The test case and the proposed code change are attached.
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Priority: Critical
>         Attachments: LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> I will attempt to attach a Test file demonstrates the issue; place it in your 
> src/test/org/apache/lucene/store/
> directory and run the unit tests with JUnit4.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Resolved] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Michael McCandless (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-3627.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0
                   3.6
    
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>             Fix For: 3.6, 4.0
>
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Updated] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ken McCracken updated LUCENE-3627:
----------------------------------

      Description: 
FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.

An initial proposed patch file is attached below.



  was:
FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.

I will attempt to attach a Test file demonstrates the issue; place it in your 
src/test/org/apache/lucene/store/
directory and run the unit tests with JUnit4.



    Lucene Fields: New,Patch Available  (was: New)
    
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Priority: Critical
>         Attachments: LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Shai Erera (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165170#comment-13165170 ] 

Shai Erera commented on LUCENE-3627:
------------------------------------

Nice catch Ken !

Patch looks good to me. Perhaps replace the msg "code will not get here" with "should have hit CrashException"? Otherwise, +1 to commit.
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Issue Comment Edited] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13164837#comment-13164837 ] 

Ken McCracken edited comment on LUCENE-3627 at 12/7/11 11:36 PM:
-----------------------------------------------------------------

Initial proposed patch.  I'm not sure if this is the correct place and scope.  But it does fix my test case.
The test case and the proposed code change are attached.

aaa:lucene kmccrack$ svn info
Path: .
URL: http://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_3_5/lucene
Repository Root: http://svn.apache.org/repos/asf
Repository UUID: 13f79535-47bb-0310-9956-ffa450edef68
Revision: 1211687
Node Kind: directory
Schedule: normal
Last Changed Author: sarowe
Last Changed Rev: 1207561
Last Changed Date: 2011-11-28 15:11:35 -0500 (Mon, 28 Nov 2011)

                
      was (Author: ken.mccracken):
    Initial proposed patch.  I'm not sure if this is the correct place and scope.  But it does fix my test case.
The test case and the proposed code change are attached.
                  
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Priority: Critical
>         Attachments: LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> I will attempt to attach a Test file demonstrates the issue; place it in your 
> src/test/org/apache/lucene/store/
> directory and run the unit tests with JUnit4.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Updated] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Michael McCandless (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless updated LUCENE-3627:
---------------------------------------

    Attachment: LUCENE-3627.patch


Thanks Ken!

I attached a new patch, whittling back the test a bit (while still
showing the bug), fixing whitespace, etc.

I also removed the @author tags (we don't attach names to the source
code...).

I fixed the bug in two places.  First, when writing the segments file,
I moved the createOutput in SegmentInfos.java inside the try/finally
that deletes the file if an exception occurs.  This way we shouldn't
create 0-byte segments_N anymore.

Second, in IndexFileDeleter I ignore a given segments_N if it's 0
bytes; I don't delete the file at that point because IFD's normal
ref-counting will eventually remove it.

                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13164816#comment-13164816 ] 

Ken McCracken commented on LUCENE-3627:
---------------------------------------

I have been reviewing https://issues.apache.org/jira/browse/LUCENE-3255 which seems related in that the error is encountered on the same section of SegmentInfos.java.
One way to fix this might be to change SegmentInfos.java as follows where int format = input.readInt(); to

        int format;
        try {
            format = input.readInt();
        } catch (IOException ioe) {
            if (input.length() == 0) {
                try {
                    input.close();
                } finally {
                    directory.deleteFile(segmentFileName);
                }
                return;
            }
            throw ioe;
        }

however, there are unit tests that seem to verify that no file deletions are happening at this low a level.  

                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Priority: Critical
>         Attachments: TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> I will attempt to attach a Test file demonstrates the issue; place it in your 
> src/test/org/apache/lucene/store/
> directory and run the unit tests with JUnit4.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Updated] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Ken McCracken (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ken McCracken updated LUCENE-3627:
----------------------------------

    Attachment: TestCrashCausesCorruptIndex.java

Drop this file in src/test/org/apache/lucene/store for the lucene 3.5.0 source release, and run your unit tests with junit4.
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>         Environment: Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Priority: Critical
>         Attachments: TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> I will attempt to attach a Test file demonstrates the issue; place it in your 
> src/test/org/apache/lucene/store/
> directory and run the unit tests with JUnit4.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[jira] [Commented] (LUCENE-3627) CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written

Posted by "Michael McCandless (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165522#comment-13165522 ] 

Michael McCandless commented on LUCENE-3627:
--------------------------------------------

Thanks Ken!

bq. What is the svn revision branch this patch would get checked in to?

Oh, I checked into 3.x (to be 3.6.0) and trunk... if you select the "All" tab here, under Activity, you can see the full SVN paths...
                
> CorruptIndexException on indexing after a failure occurs after segments file creation but before any bytes are written
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3627
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3627
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: lucene-3.5.0, src download from GA release lucene.apache.org.
> Mac OS X 10.6.5, running tests in Eclipse Build id: 20100218-1602, 
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
>            Reporter: Ken McCracken
>            Assignee: Michael McCandless
>            Priority: Critical
>             Fix For: 3.6, 4.0
>
>         Attachments: LUCENE-3627.patch, LUCENE-3627_initial_proposal.txt, TestCrashCausesCorruptIndex.java
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> FSDirectory.createOutput(..) uses a RandomAccessFile to do its work.  On my system the default FSDirectory.open(..) creates an NIOFSDirectory.  If createOutput is called on a segments_* file and a crash occurs between RandomAccessFile creation (file system shows a segments_* file exists but has zero bytes) but before any bytes are written to the file, subsequent IndexWriters cannot proceed.  The difficulty is that it does not know how to clear the empty segments_* file.  None of the file deletions will happen on such a segment file because the opening bytes cannot not be read to determine format and version.
> An initial proposed patch file is attached below.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org