Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-9138

Behaviour of concurrent calls to IndexInput#clone is unclear

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 8.4
    • Fix Version/s: None
    • Component/s: core/store
    • Labels:
      None
    • Lucene Fields:
      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()?
       
       
       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              David Turner David Turner
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: