Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 78642 invoked from network); 10 Nov 2006 11:32:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Nov 2006 11:32:03 -0000 Received: (qmail 43273 invoked by uid 500); 10 Nov 2006 11:32:11 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 43229 invoked by uid 500); 10 Nov 2006 11:32:11 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 43218 invoked by uid 99); 10 Nov 2006 11:32:11 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 03:32:11 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 03:32:00 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A045B7142FC for ; Fri, 10 Nov 2006 03:31:39 -0800 (PST) Message-ID: <9760632.1163158299653.JavaMail.jira@brutus> Date: Fri, 10 Nov 2006 03:31:39 -0800 (PST) From: "Michael McCandless (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Commented: (LUCENE-554) Possible index corruption if crashing while replacing segments file In-Reply-To: <11290508.1145789825731.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/LUCENE-554?page=comments#action_12448707 ] Michael McCandless commented on LUCENE-554: ------------------------------------------- With lockless commits LUCENE-701 (which does not use file renaming at all) this issue will be resolved. > Possible index corruption if crashing while replacing segments file > ------------------------------------------------------------------- > > Key: LUCENE-554 > URL: http://issues.apache.org/jira/browse/LUCENE-554 > Project: Lucene - Java > Issue Type: Bug > Components: Index > Affects Versions: 1.9 > Reporter: Nadav Har'El > Priority: Minor > > Lucene's indexing is expected to be reasonably tolerant to computer crashes or the indexing process being killed. By reasonably tolerant, I mean that it is ok to lose a few documents (those currently buffered in memory), or have to repeat some work (e.g., a long merge that was in progress) - but it is not ok for the entire index, or large chunks of it, to become irreversebly corrupt. > The fact that Lucene works by repeated merging of several small segments into a new larger segments, solves most of the crash problems, because until the new segment is fully created, the old segments are still there and fully functional. However, one possibility for corruption remains in the segment replacement code: > After a new segment is created, a new segments file is written as a new file "segments.new", and then this file is renamed to "segments". The problem is that this renaming is done using Directory.renameFile(), and FSDirectory.renameFile is *NOT* atomic: it first deletes the old file, and then renames the new file. A crash between these stages (or perhaps during Java's rename which also isn't guaranteed to be atomic) will potentially leave us without a working "segments" file. > I will post here a patch for this bug shortly. > The patch will also include a change to Directory.renameFile()'s Javadoc. It currently claims "This replacement should be atomic.", which is false in FSDirectory. Instead it should make a weaker claim, for example > "This replacement does not have to be atomic, but must at least obey a weaker guarantee: at any time during the replacement, either the "from" file is still available, or the "to" file is available with either the new or old content." > (or, we can just drop the guaranteee altogether, like Java's File.renameTo() provides no atomic-ness guarantees). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org