OpenJPA
  1. OpenJPA
  2. OPENJPA-653

Concurrency issue with query cache enabled

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.2.0
    • Component/s: datacache
    • Labels:
      None

      Description

      A Java EE application with query result caching enabled and with many concurrent users is failing with a ConcurrentModificationException in org.apache.openjpa.datacache.QueryCacheStoreQuery. Specifically, the failure is in the inner class.method CachingResultObjectProvider.checkFinished(Object, boolean) and occurs while iterating the _data TreeMap within the QueryResult constructor.

      Examination of this method showed that the tree map is synchronized in the beginning of the method and then later when the map is cleared in abortCaching(). It is not synchronized when a new QueryResult is constructed. This allows a thread to iterate over the map (during the constructor) while another thread is modifying it.

      1. OPENJPA-653.patch
        0.9 kB
        Jeremy Bauer

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        5h 30m 1 Albert Lee 07/Jul/08 20:44
        Resolved Resolved Closed Closed
        609d 22h 47m 1 Donald Woods 09/Mar/10 18:32
        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Michael Dick made changes -
        Assignee Michael Dick [ mikedd ] Jeremy Bauer [ techhusky ]
        Albert Lee made changes -
        Fix Version/s 1.2.0 [ 12313102 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Michael Dick made changes -
        Assignee Michael Dick [ mikedd ]
        Jeremy Bauer made changes -
        Field Original Value New Value
        Attachment OPENJPA-653.patch [ 12385412 ]
        Hide
        Jeremy Bauer added a comment -

        Attaching patch for 1.2.0/trunk which synchronizes the data tree map over QueryResult construction. I considered making the TreeMap object a synchronized sorted map, but the JavaDoc indicated that an external synch was still necessary when iterating the collection. Sadly, due to the nature of the problem I have not been able to produce a jUnit which reproduces the failure. If I am able to produce a test I will post it at a later date.

        Please review and if no issues, commit for 1.2.0.

        Show
        Jeremy Bauer added a comment - Attaching patch for 1.2.0/trunk which synchronizes the data tree map over QueryResult construction. I considered making the TreeMap object a synchronized sorted map, but the JavaDoc indicated that an external synch was still necessary when iterating the collection. Sadly, due to the nature of the problem I have not been able to produce a jUnit which reproduces the failure. If I am able to produce a test I will post it at a later date. Please review and if no issues, commit for 1.2.0.
        Jeremy Bauer created issue -

          People

          • Assignee:
            Jeremy Bauer
            Reporter:
            Jeremy Bauer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development