IBM Support

PM94033: Incorrect locking behavior with JPA PESSIMISTIC_LOCK mode

Fixes are available

8.5.5.2: WebSphere Application Server V8.5.5 Fix Pack 2
8.0.0.9: WebSphere Application Server V8.0 Fix Pack 9
8.5.5.3: WebSphere Application Server V8.5.5 Fix Pack 3
8.5.5.4: WebSphere Application Server V8.5.5 Fix Pack 4
8.0.0.10: WebSphere Application Server V8.0 Fix Pack 10
8.5.5.5: WebSphere Application Server V8.5.5 Fix Pack 5
8.5.5.6: WebSphere Application Server V8.5.5 Fix Pack 6
8.0.0.11: WebSphere Application Server V8.0 Fix Pack 11
8.5.5.7: WebSphere Application Server V8.5.5 Fix Pack 7
8.5.5.8: WebSphere Application Server V8.5.5 Fix Pack 8
8.0.0.12: WebSphere Application Server V8.0 Fix Pack 12
8.5.5.9: WebSphere Application Server V8.5.5 Fix Pack 9
8.5.5.10: WebSphere Application Server V8.5.5 Fix Pack 10
8.5.5.11: WebSphere Application Server V8.5.5 Fix Pack 11
8.0.0.13: WebSphere Application Server V8.0 Fix Pack 13
8.5.5.12: WebSphere Application Server V8.5.5 Fix Pack 12
8.0.0.14: WebSphere Application Server V8.0 Fix Pack 14
8.5.5.13: WebSphere Application Server V8.5.5 Fix Pack 13
8.0.0.15: WebSphere Application Server V8.0 Fix Pack 15
8.5.5.14: WebSphere Application Server V8.5.5 Fix Pack 14
8.5.5.15: WebSphere Application Server V8.5.5 Fix Pack 15
8.5.5.14: WebSphere Application Server V8.5.5 Fix Pack 14
8.5.5.17: WebSphere Application Server V8.5.5 Fix Pack 17
8.5.5.20: WebSphere Application Server V8.5.5.20
8.5.5.18: WebSphere Application Server V8.5.5 Fix Pack 18
8.5.5.19: WebSphere Application Server V8.5.5 Fix Pack 19
8.5.5.16: WebSphere Application Server V8.5.5 Fix Pack 16
8.5.5.21: WebSphere Application Server V8.5.5.21

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • In a multi-threaded environment, when a JPA 2.0 application
    running in WebSphere Application Server executes
    EntityManager.refresh() with LockModeType.PESSIMISTIC_LOCK, the
    JPA implementation first reads the records from the database and
    then locks the records, rather than locking immediately.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.0.0, V8.5.0, and V8.5.5           *
    *                  who make use of JPA                         *
    *                  LockModeType.PESSIMISTIC_WRITE.             *
    ****************************************************************
    * PROBLEM DESCRIPTION: Calling                                 *
    *                      EntityManager.refresh(PESSIMISTIC_WRITE *
    *                      ) generates seperate SQL for the lock.  *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Take the following JPA scenario:
    EntityManager em.....
    T1 t1 = em.find(T1.class, "c1");
    em.refresh(t1, LockModeType.PESSIMISTIC_WRITE);
    Object T1 is a JPA entity; the details of the entity are not
    important.  When the 'refresh' occurs, the following two SQL
    statements will be run (these statements are from DB2,
    statements generated for other databses will be slightly
    different, but the results are the same):
    SELECT t0.CMLT_FOLDER_CONTEXT_UPDATE_TMS, t0.CRE_TIME FROM T1
    t0 WHERE t0.c1 = ?  [params=(String) c1]
    SELECT t0.c1 FROM T1 t0 WHERE t0.c1 = ?  FOR READ ONLY WITH RR
    USE AND KEEP UPDATE LOCKS [params=(String) c1]
    As can be seen, the second SQL statement will get a
    pessimistic lock for the row.  However, two SQL selects to get
    the lock should not be necessary, one would suffice.
    Furthermore, in a multi-threaded environment the time between
    the two selects might allow another thread the lock over other
    competing rows.
    

Problem conclusion

  • With this fix, code has been added to OpenJPA to ensure only
    one SQL is generated when getting a lock for an entity.  With
    the fix, only one select will be generated, as follows:
    SELECT t0.CMLT_FOLDER_CONTEXT_UPDATE_TMS, t0.CRE_TIME FROM T1
    t0 WHERE t0.c1 = ? FOR UPDATE [params=(String) c1]
    
    The fix for this APAR is currently targeted for
    inclusion in Service Levels (Fix Packs) 8.0.0.9 and 8.5.5.2 of
    WebSphere Application Server versions 8.0.0 and 8.5.5.
    
    Please refer to the recommended updates page for delivery
    information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

Comments

APAR Information

  • APAR number

    PM94033

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2013-07-29

  • Closed date

    2013-11-19

  • Last modified date

    2013-11-19

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    WEBS APP SERV N

  • Fixed component ID

    5724H8800

Applicable component levels

  • R800 PSY

       UP

  • R850 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.0","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
27 April 2022