Lucene - Core
  1. Lucene - Core
  2. LUCENE-5684

Add best effort detection when index is removed & recreated before openIfChanged

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.9, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      I dug into the confusing NPE from the java-user email with subject "[lucene 4.6] NPE when calling IndexReader#openIfChanged".

      It happens because the app was opening an IndexReader, then rm -rf the entire index, build a new one, then calling reopen. This is invalid usage (the app should instead use IW.deleteAll, or open new IW with OpenMode.CREATE), but I'd like to add a minor best effort check...

      1. LUCENE-5684.patch
        13 kB
        Michael McCandless
      2. LUCENE-5684.patch
        11 kB
        Michael McCandless

        Activity

        Hide
        Michael McCandless added a comment -

        Patch, I think it's ready. I also tried to clean up StandardDirectoryReader.open a bit: it was scary how it would assign to newReaders[i] a non-incRef'd reader. I was sure it was a bug, and made a test case to show it, but the test case wouldn't fail and on staring at the code some more I noticed the i++ in the finally clause that prevents the bug ...

        Show
        Michael McCandless added a comment - Patch, I think it's ready. I also tried to clean up StandardDirectoryReader.open a bit: it was scary how it would assign to newReaders [i] a non-incRef'd reader. I was sure it was a bug, and made a test case to show it, but the test case wouldn't fail and on staring at the code some more I noticed the i++ in the finally clause that prevents the bug ...
        Hide
        Michael McCandless added a comment -

        Another iteration, more simplifications, I think it's ready.

        Show
        Michael McCandless added a comment - Another iteration, more simplifications, I think it's ready.
        Hide
        Robert Muir added a comment -

        This looks awesome!

        Show
        Robert Muir added a comment - This looks awesome!
        Hide
        ASF subversion and git services added a comment -

        Commit 1597050 from Michael McCandless in branch 'dev/trunk'
        [ https://svn.apache.org/r1597050 ]

        LUCENE-5684: best effort detection of (illegal) reopen after index was blown away

        Show
        ASF subversion and git services added a comment - Commit 1597050 from Michael McCandless in branch 'dev/trunk' [ https://svn.apache.org/r1597050 ] LUCENE-5684 : best effort detection of (illegal) reopen after index was blown away
        Hide
        ASF subversion and git services added a comment -

        Commit 1597052 from Michael McCandless in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1597052 ]

        LUCENE-5684: best effort detection of (illegal) reopen after index was blown away

        Show
        ASF subversion and git services added a comment - Commit 1597052 from Michael McCandless in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1597052 ] LUCENE-5684 : best effort detection of (illegal) reopen after index was blown away

          People

          • Assignee:
            Michael McCandless
            Reporter:
            Michael McCandless
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development