[ https://issues.apache.org/jira/browse/LUCENE-743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12538743 ]
Michael McCandless commented on LUCENE-743: ------------------------------------------- OK I think this patch is very close! I finished reviewing it -- here's some more feedback: - In multiple places you catch an IOException and undo the attempted re-open, but shouldn't this be a try/finally instead so you also clean up on hitting any unchecked exceptions? - I think you need an explicit refCount for the Norm class in SegmentReader. . Say I've done a chain of 10 re-opens for SegmentReader and each time only the segment's norms has changed. I've closed all but the last SegmentReader. At this point all 10 SegmentReaders are still alive (RC > 0) and holding open all file handles for their copies of the norms. So this will leak file handles/RAM with each reopen? . To fix this, I think you just need to add refCount into Norm class & set refCount to 1 in the constructor. Then, each each SegmentReader calls Norm.decRef(), not Norm.close(), when it's done. When refCount hits 0 then the Norm closes itself. Finally, during re-open you should share a Norm instance (rather than open a new one) if it had not changed from the previous SegmentReader. . For singleNormStream, I think each reopened SegmentReader should always re-open this descriptor and then we can forcefully close this stream when the SegmentReader is closed (what you are doing now). Ie the SegmentReader fully owns singleNormStream. - If you have a long series of reopens, then, all SegmentReaders in the chain will remain alive. So this is a [small] memory leak with time. I think if you changed referencedSegmentReader to always be the *starting* SegmentReader then this chain is broken and after 10 reopens only the original SegmentReader and the most recent one will remain alive (assuming I closed all SegmentReaders but the most recent one). > IndexReader.reopen() > -------------------- > > Key: LUCENE-743 > URL: https://issues.apache.org/jira/browse/LUCENE-743 > Project: Lucene - Java > Issue Type: Improvement > Components: Index > Reporter: Otis Gospodnetic > Assignee: Michael Busch > Priority: Minor > Fix For: 2.3 > > Attachments: IndexReaderUtils.java, lucene-743-take2.patch, > lucene-743-take3.patch, lucene-743.patch, lucene-743.patch, lucene-743.patch, > MyMultiReader.java, MySegmentReader.java, > varient-no-isCloneSupported.BROKEN.patch > > > This is Robert Engels' implementation of IndexReader.reopen() functionality, > as a set of 3 new classes (this was easier for him to implement, but should > probably be folded into the core, if this looks good). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]