Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1519

Change Primitive Data Types from int to long in class SegmentMerger.java

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4.1, 2.9
    • Component/s: None
    • Labels:
      None
    • Environment:

      lucene 2.4.0, jdk1.6.0_03/07/11

    • Lucene Fields:
      New

      Description

      Hi

      We are getting an exception while optimize. We are getting this exception "mergeFields produced an invalid result: docCount is 385282378 but fdx file size is 3082259028; now aborting this merge to prevent index corruption"

      I have checked the code for class SegmentMerger.java and found this check

      ***********************************************************************************************************************************************************************
      if (4+docCount*8 != fdxFileLength)
      // This is most likely a bug in Sun JRE 1.6.0_04/_05;
      // we detect that the bug has struck, here, and
      // throw an exception to prevent the corruption from
      // entering the index. See LUCENE-1282 for
      // details.
      throw new RuntimeException("mergeFields produced an invalid result: docCount is " + docCount + " but fdx file size is " + fdxFileLength + "; now aborting this merge to prevent index corruption");
      }
      ***********************************************************************************************************************************************************************

      In our case docCount is 385282378 and fdxFileLength size is 3082259028, even though 4+385282378*8 is equal to 3082259028, the above code will not work because number 3082259028 is out of int range. So type of variable docCount needs to be changed to long

      I have written a small test for this

      ************************************************************************************************************************************************************************

      public class SegmentMergerTest {
      public static void main(String[] args) {
      int docCount = 385282378;
      long fdxFileLength = 3082259028L;
      if(4+docCount*8 != fdxFileLength)
      System.out.println("No Match" + (4+docCount*8));
      else
      System.out.println("Match" + (4+docCount*8));
      }
      }

      ************************************************************************************************************************************************************************

      Above test will print No Match but if you change the data type of docCount to long, it will print Match

      Can you please advise us if this issue will be fixed in next release?

      Regards
      Deepak

        Issue Links

          Activity

          Hide
          otis Otis Gospodnetic added a comment -

          Deepak - could you please bring this up on the java-user mailing list instead and close this issue?

          Show
          otis Otis Gospodnetic added a comment - Deepak - could you please bring this up on the java-user mailing list instead and close this issue?
          Hide
          kalradeepak Deepak added a comment -

          Hi Otis

          It is a lucene bug. Is there any other mail list for reporting lucene java bug. then please send me the link

          Regards
          Deepak

          Show
          kalradeepak Deepak added a comment - Hi Otis It is a lucene bug. Is there any other mail list for reporting lucene java bug. then please send me the link Regards Deepak
          Hide
          mikemccand Michael McCandless added a comment -

          Grr – the bug is real. I'll fix.

          Show
          mikemccand Michael McCandless added a comment - Grr – the bug is real. I'll fix.
          Hide
          mikemccand Michael McCandless added a comment -

          Committed revision 734415.

          Thanks Deepak!

          Show
          mikemccand Michael McCandless added a comment - Committed revision 734415. Thanks Deepak!
          Hide
          kalradeepak Deepak added a comment -

          No problem

          Show
          kalradeepak Deepak added a comment - No problem
          Hide
          mikemccand Michael McCandless added a comment -

          Reopening for backport to 2.4.1.

          Show
          mikemccand Michael McCandless added a comment - Reopening for backport to 2.4.1.
          Hide
          mikemccand Michael McCandless added a comment -

          Committed revision 745801 on 2.4 branch.

          Show
          mikemccand Michael McCandless added a comment - Committed revision 745801 on 2.4 branch.

            People

            • Assignee:
              mikemccand Michael McCandless
              Reporter:
              kalradeepak Deepak
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development