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

FieldNumbers.clear() should reset lowestUnassignedFieldNumber

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 8.7
    • Fix Version/s: 8.8
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      A call to IndexWriter.deleteAll() should completely reset the state of the index. Part of that is a call to globalFieldNumbersMap.clear(), which purges all knowledge of fields by clearing name -> number and number -> name maps. However, it does not reset lowestUnassignedFieldNumber.

      If we have loop that adds some documents, calls deleteAll(), adds documents, etc. lowestUnassignedFieldNumber keeps counting up. Since FieldInfos allocates an array for number -> FieldInfo, this array will get larger and larger, effectively leaking memory.

      We can fix this by resetting lowestUnassignedFieldNumber to -1 in FieldNumbers.clear().

      I'll write a unit test and attach a patch.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              msfroh Michael Froh

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 3h 50m
                3h 50m

                  Issue deployment