Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2019

2 connections can be opened simultaneously during some DataCache work inside single query.getResultList()



    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0.0
    • None
    • datacache, kernel, query
    • None
    • WinXP SP3, JDK 1.6.0_21, Postgres


      Test configuration:

      public class Document

      { ... }

      public class Person {
      @JoinTable(name="person_document", joinColumns =

      {@JoinColumn(name="person_id", referencedColumnName="ID")}

      , inverseJoinColumns =

      {@JoinColumn(name="documents_id", referencedColumnName="ID")}

      @OneToMany(fetch = FetchType.EAGER)
      private List<Document> documents;

      Test case:
      0. Set DataCache to: true(CacheSize=40, SoftReferenceSize=0), and limit connection pool size by 1 connection
      1. Create 20 objects of Person entity (+ 3 documents per each Person): 80 objects total (only half of objects can be located in data cache)
      2. Clear entity manager and run query "SELECT p FROM Person p WHERE p.id IN (?1, ?2, ... , ?20)"
      Openjpa tries to open second connection at some time and fails.

      The problem is significant for me because I have lots of threads executing queries like in 2. point and I have hard limits on connection pool size. I cannot have connection_pool_size > possible_threads_count. So at some time I get connection pool exhausted and application stops working.

      It seems that the problem is related to DataCache work and L1 cache work (I didn't reproduce the problem with big sized or small sized DataCache - to reproduce it's better to assign DataCache size = 1/2 of total query objects count. Also I didn't reproduce it with Ehcache and openjpa-2.2.0 with Lru=true).

      Attached test project and stack trace of getting second connection.

      Sometimes test can successfully finish (~5-10% of all runs) - it's hard to make it deterministic.


        1. jpa_datacache_stack_trace.txt
          5 kB
          Oleg Lyalikov
        2. jpa-data-cache.zip
          7 kB
          Oleg Lyalikov



            Unassigned Unassigned
            oleg.lyalikov Oleg Lyalikov
            2 Vote for this issue
            2 Start watching this issue