Uploaded image for project: 'MusicBrainz Search Server'
  1. MusicBrainz Search Server
  2. SEARCH-140

reloadIndex should ensure closes old searcher and reader

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 2011-09-28
    • Fix Version/s: 2011-09-28
    • Component/s: None
    • Labels:
      None

      Description

      reloadIndex() is called when we have new indexes because it is quicker then initlizing from scratch, but if the reader has changed we don't appear to be closing the older reader

      Current Code:

       public void reloadIndex() throws CorruptIndexException, IOException {
          	
          	if (this.indexSearcher != null) {
          		IndexReader oldReader = indexSearcher.getIndexReader();
      			IndexReader newReader = oldReader.reopen();
      			if (oldReader != newReader) {
      				Similarity similarity = indexSearcher.getSimilarity();
      				this.indexSearcher = new IndexSearcher(newReader);
      				this.indexSearcher.setSimilarity(similarity);
      				this.setLastServerUpdatedDate();
      			}
          	}
          }
      

      New Code:

       public void reloadIndex() throws CorruptIndexException, IOException {
          	
          	if (this.indexSearcher != null) {
          		IndexReader oldReader = indexSearcher.getIndexReader();
      			IndexReader newReader = oldReader.reopen();
      			if (oldReader != newReader) {
      				Similarity similarity = indexSearcher.getSimilarity();
      				this.indexSearcher = new IndexSearcher(newReader);
      				this.indexSearcher.setSimilarity(similarity);
      				this.setLastServerUpdatedDate();
                                      indexSearcher.close();
      			}
          	}
          }
      

        Attachments

          Activity

            People

            Assignee:
            ijabz Paul Taylor
            Reporter:
            ijabz Paul Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                2011-09-28