[ 
https://issues.apache.org/jira/browse/LUCENE-6745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14706779#comment-14706779
 ] 

Robert Muir commented on LUCENE-6745:
-------------------------------------

{quote}
Instead, I think the bug is in BKDDVFormat, because it's doing "real stuff" 
with the original IndexInput it opened, instead of always using clones to do so 
...
{quote}

In my opinion the API is trappy here. There are two ways i see this currently 
done today:
* codec opens an immutable IndexInput, clone()s off that. Its ok without sync 
because it does not modify the original.
* codec protects clone() with sync.

Long term, maybe we should explore enforcing the first one with the API to 
prevent crazy stuff. In other words, Directory would return a Handle or 
Descriptor, that represents the actual FD opened. And it really has no 
conceptual state, you cannot really do anything with it except close it and get 
IndexInputs from it.

I do hate the additional abstraction, however the more I think about it, the 
more I think its better: it would just be representing what actually happens 
today, but without the thread safety bugs of using IndexInput for both purposes.

> RAMInputStream.clone is not thread safe
> ---------------------------------------
>
>                 Key: LUCENE-6745
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6745
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: Trunk, 5.4
>
>         Attachments: LUCENE-6745.patch
>
>
> This took some time to track down ... it's the root cause of the RangeTree 
> failures that [~steve_rowe] found at 
> https://issues.apache.org/jira/browse/LUCENE-6697?focusedCommentId=14696999&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14696999
> The problem happens when one thread is using the original IndexInput 
> (RAMInputStream) from a RAMDirectory, but other threads are also cloning  
> that IndexInput at the same time.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to