You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Simon Willnauer (JIRA)" <ji...@apache.org> on 2014/03/25 15:51:15 UTC

[jira] [Updated] (LUCENE-5553) IndexReader#ReaderClosedListener is not always called on IndexReader#close()

     [ https://issues.apache.org/jira/browse/LUCENE-5553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simon Willnauer updated LUCENE-5553:
------------------------------------

    Attachment: LUCENE-5553.patch

here is a patch that adds a tests for the index reader including faulty listeners etc. I tried to fix the entire chain down to SCR and I dropped putting the reference back since this should really just close everything and hand the exception back. Shai is right you can call it again but this might not help since in some cases the exception is thrown again and that means it leaves you with a half broken reader. It also feels completly odd to call decRef more than once and a close call should close and shouldn't leave a broken reader behind.



> IndexReader#ReaderClosedListener is not always called on IndexReader#close()
> ----------------------------------------------------------------------------
>
>                 Key: LUCENE-5553
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5553
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.7, 5.0
>            Reporter: Simon Willnauer
>            Priority: Blocker
>             Fix For: 4.7.1
>
>         Attachments: LUCENE-5553.patch
>
>
> Today IndexReader#ReaderClosedListener might not be called if the last IndexReader#decRef() call runs into an exception on IndexReader#doClose(). Today we just reset the refCount and never go and call the listeners. There seem to be a bunch of problems here along the same lines but IMO if we close a reader it should close all resources no matter what exception it runs into. What this should do is call the close listeners in a finally block and then rethrow the exception. The real problem here for apps relying on the listener to release resources is that you might leak memory or file handles or whatnot which I think is a bug how we handle closing the IR. As a side-note I think we should never reset the reference here to be honest.  
> Along the same lines I think we need to fix the loop in IndexReader#notifyReaderClosedListeners() to make sure we call all of them in the case any of them throws an exception. It also seems that SegmentCoreReaders#decRef() has a similar problem where for instance a fieldsReader can throw an exception on close and we never call the core listeners.
> IMO we need to fix this for 4.7.1 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org