Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-5

IndexLARQ is not thread safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Done
    • None
    • Jena 2.11.0
    • ARQ
    • None

    Description

      Copying a previously sent email:

      I ran into a concurrency problem in LARQ. When I try to run concurrent queries the Lucene query parser barfs.

      After a bit of digging, I think I understand what is going on. I was creating an IndexLARQ and setting that as the global index, then running my queries. The IndexLARQ constructor constructs a Lucene QueryParser object which it uses for all queries. Lucene QueryParser objects are not thread safe, so multiple concurrent queries cause the parser the barf.

      I have had a go at patching the HEAD from SVN. Basically I make the QueryParser object in IndexLARQ ThreadLocal.

      The problem with this is that there is a constructor to IndexLARQ which takes an externally provided QueryParser object and QueryParser is not clonable. I could replicate the query parser for each thread provided I know its a QueryParser and not a subclass of QueryParser. If someone passed in a subclass of QueryParser I'd go creating the wrong class of objects as a replica.

      Whilst this scenario is not very likely, since I think the constructor should be deprecated anyway, what I've done is esentially left that constructor alone. Creating an IndexLARQ with that contructor will continue to construct one that is not thread safe. The other constructors will construct threadsafe instances.

      Attached are:

      a modified IndexLARQ.java that fixes the problem as I've described.
      TestLARQConcurrent.java - a test case
      larqConcurrentPatch - a patch file that applies the changes

      Oops - Just noticed the license notice on the test case file - you will want to change that if you use this.

      hmmm - there doesn't seem to be a button here for attaching files.

      Attachments

        1. TestLARQConcurrent.java
          3 kB
          Brian McBride
        2. IndexLARQ.java
          8 kB
          Brian McBride
        3. larqConcurrentPatch
          6 kB
          Brian McBride

        Activity

          People

            andy Andy Seaborne
            bwm Brian McBride
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: