You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Geoff Cooney <co...@gmail.com> on 2013/05/16 16:45:11 UTC
CorruptIndexException when opening Index during first commit
Hi,
We're occasionally seeing a CorruptIndexException when a searcher is opened
on a new index.
When we see the exception, it looks like what is happening is that the
searcher is opening the index after prepareCommit for segments_1 but before
the commit is completed. Because there is no prior commit to fall back to,
lucene throws the CorruptIndexException. Does this sounds feasible and is
it a bug? My expectation is that lucene would treat the index as
nonexistent until the first commit is completed.
We're running lucene 3.5.
Cheers,
Geoff
Re: CorruptIndexException when opening Index during first commit
Posted by Michael McCandless <lu...@mikemccandless.com>.
OK I opened https://issues.apache.org/jira/browse/LUCENE-5024 ...
Geoff can you describe your idea there? Thanks.
Mike McCandless
http://blog.mikemccandless.com
On Thu, May 30, 2013 at 7:35 AM, Michael McCandless
<lu...@mikemccandless.com> wrote:
> On Mon, May 20, 2013 at 9:22 AM, Geoff Cooney <co...@gmail.com> wrote:
>>> The problem is we can't reliably differentiate commit-in-progress from
>>> a corrupt first commit...
>>
>> I think you can tell them apart with high probability because the checksum
>> is off by exactly one(at least in lucene 3.5 where I'm looking). It does
>> seem dangerous to rely on an implementation detail of the pre-commit like
>> this, though. Is there a reason lucene couldn't write a "isCommitted" byte
>> to segments_n and use this byte to detect pre-committed segments reliably?
>
> I'll open a new issue to explore these ideas ... it would be best if
> we could detect "incomplete first commit".
>
> Mike McCandless
>
> http://blog.mikemccandless.com
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: CorruptIndexException when opening Index during first commit
Posted by Michael McCandless <lu...@mikemccandless.com>.
On Mon, May 20, 2013 at 9:22 AM, Geoff Cooney <co...@gmail.com> wrote:
>> The problem is we can't reliably differentiate commit-in-progress from
>> a corrupt first commit...
>
> I think you can tell them apart with high probability because the checksum
> is off by exactly one(at least in lucene 3.5 where I'm looking). It does
> seem dangerous to rely on an implementation detail of the pre-commit like
> this, though. Is there a reason lucene couldn't write a "isCommitted" byte
> to segments_n and use this byte to detect pre-committed segments reliably?
I'll open a new issue to explore these ideas ... it would be best if
we could detect "incomplete first commit".
Mike McCandless
http://blog.mikemccandless.com
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: CorruptIndexException when opening Index during first commit
Posted by Geoff Cooney <co...@gmail.com>.
> The problem is we can't reliably differentiate commit-in-progress from
> a corrupt first commit...
I think you can tell them apart with high probability because the checksum
is off by exactly one(at least in lucene 3.5 where I'm looking). It does
seem dangerous to rely on an implementation detail of the pre-commit like
this, though. Is there a reason lucene couldn't write a "isCommitted" byte
to segments_n and use this byte to detect pre-committed segments reliably?
Cheers,
Geoff
Re: CorruptIndexException when opening Index during first commit
Posted by Michael McCandless <lu...@mikemccandless.com>.
On Thu, May 16, 2013 at 2:59 PM, Geoff Cooney <co...@gmail.com> wrote:
> Thanks for the response, Mike.
>
> If I understand correctly, the problem was incorrectly identifying a large
> corrupted index as a non-existant index?
Actually, a large healthy index as non-existent (because of file
descriptor exhaustion).
> It seems like you'd really want
> an index with first-commit in progress to behave like an index with zero
> documents, as opposed to a non-existant index. That is, if segments_1 is
> corrupt, open an empty index. This seems more analagous to how lucene
> treats pre-committed segments_n files after the first. I don't know how
> difficult it would be to implement, in practice.
Hmm, I think first-commit in progress should really act like no index
exists yet. If we instead act
like a 0-docs index that can mask true corruption.
The problem is we can't reliably differentiate commit-in-progress from
a corrupt first commit...
> This isn't a major issue for us either way. We can work around it by
> having our searcher code check for the existence of a segments.gen and just
> return zero hits by default. Since this is a read path only, we don't need
> to worry about incorrectly overwriting the index.
Ahh sneaky but that should work (unless IW changes its index format
wrt segments.gen).
Mike McCandless
http://blog.mikemccandless.com
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: CorruptIndexException when opening Index during first commit
Posted by Geoff Cooney <co...@gmail.com>.
Thanks for the response, Mike.
If I understand correctly, the problem was incorrectly identifying a large
corrupted index as a non-existant index? It seems like you'd really want
an index with first-commit in progress to behave like an index with zero
documents, as opposed to a non-existant index. That is, if segments_1 is
corrupt, open an empty index. This seems more analagous to how lucene
treats pre-committed segments_n files after the first. I don't know how
difficult it would be to implement, in practice.
This isn't a major issue for us either way. We can work around it by
having our searcher code check for the existence of a segments.gen and just
return zero hits by default. Since this is a read path only, we don't need
to worry about incorrectly overwriting the index.
Cheers,
Geoff
On Thu, May 16, 2013 at 1:47 PM, Michael McCandless <
lucene@mikemccandless.com> wrote:
> Unfortunately this is expected behavior.
>
> We tried to fix it in LUCENE-2812, but this fix was too dangerous and
> could sometimes erase a good index (if transient IOExcs are happening,
> e.g. due to file descriptor exhaustion) so we reverted back in
> LUCENE-4738, so that indexExists will return true, and trying to open
> an IndexReader will throw CorruptIndexException, when the first-commit
> has started but not yet finished.
>
> Mike McCandless
>
> http://blog.mikemccandless.com
>
>
> On Thu, May 16, 2013 at 10:45 AM, Geoff Cooney <co...@gmail.com>
> wrote:
> > Hi,
> >
> > We're occasionally seeing a CorruptIndexException when a searcher is
> opened
> > on a new index.
> >
> > When we see the exception, it looks like what is happening is that the
> > searcher is opening the index after prepareCommit for segments_1 but
> before
> > the commit is completed. Because there is no prior commit to fall back
> to,
> > lucene throws the CorruptIndexException. Does this sounds feasible and
> is
> > it a bug? My expectation is that lucene would treat the index as
> > nonexistent until the first commit is completed.
> >
> > We're running lucene 3.5.
> >
> > Cheers,
> > Geoff
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
Re: CorruptIndexException when opening Index during first commit
Posted by Michael McCandless <lu...@mikemccandless.com>.
Unfortunately this is expected behavior.
We tried to fix it in LUCENE-2812, but this fix was too dangerous and
could sometimes erase a good index (if transient IOExcs are happening,
e.g. due to file descriptor exhaustion) so we reverted back in
LUCENE-4738, so that indexExists will return true, and trying to open
an IndexReader will throw CorruptIndexException, when the first-commit
has started but not yet finished.
Mike McCandless
http://blog.mikemccandless.com
On Thu, May 16, 2013 at 10:45 AM, Geoff Cooney <co...@gmail.com> wrote:
> Hi,
>
> We're occasionally seeing a CorruptIndexException when a searcher is opened
> on a new index.
>
> When we see the exception, it looks like what is happening is that the
> searcher is opening the index after prepareCommit for segments_1 but before
> the commit is completed. Because there is no prior commit to fall back to,
> lucene throws the CorruptIndexException. Does this sounds feasible and is
> it a bug? My expectation is that lucene would treat the index as
> nonexistent until the first commit is completed.
>
> We're running lucene 3.5.
>
> Cheers,
> Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org