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

PESSIMISTIC_READ takes out exclusive lock on Postgres

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4.2, 3.0.0, 3.1.0
    • 3.2.3
    • kernel
    • None

    Description

      I've found out that using PESSIMISTIC_READ on an entity with postgres
      uses 'for update' lock, which is actually exclusive.

      I understand JPA specification says that it's permissible to do that,
      but I really need a shared lock for what I'm trying to achieve.

      Is it possible to control somehow? I've had to resolve to using native
      queries, and I'd like to avoid this as much as possible...

      Attached is a test.
      Change App.java to control database properties for connection (top of `main()`)
      Run App.class to execute the test. If the lock taken by OpenJPA is exclusive, then native query will fail (with an exception).
      I'm testing on Postgres 9.6
      Tested with 2.4.2, 3.0.0 and 3.1.0

      Attachments

        1. openjpa-lock.zip
          9 kB
          Pawel Veselov

        Activity

          People

            struberg Mark Struberg
            pveselov Pawel Veselov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: