Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
8.4
-
None
-
None
-
New
Description
I think this is a documentation issue, rather than anything actually wrong, but need expert guidance to propose a fix.
The Javadocs for IndexInput#clone warn that it is not thread safe:
- <p>This method is NOT thread safe, so if the current {@code IndexInput}
- is being used by one thread while {@code clone} is called by another,
- disaster could strike.
*/
@Override
public IndexInput clone() {
However, there are places where clone() may be called concurrently. For instance I believe SegmentReader#getFieldsReader clones an IndexInput and requires no extra synchronization. I think this comment is supposed to mean that you should not clone() an IndexInput while you're reading or seeking from it concurrently, but the precise guarantees aren't totally clear.
Furthermore there's no mention of the threadsafety of slice() and there seem to be similar concurrent usages of it in e.g. Lucene80DocValuesProducer. Does this have the same guarantees as clone()?