Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-3619

XA END / un-enlist for database connection called before all persistence units have performed database updates




      While trying to port an EE application from JBoss5 to WF8 the following problem occurred:

      EJBs (@Required) using JPA to do some data changes.
      Some changes get already written to the database, others reside in the session cache.

      After the top EJB call returns, a Hibernate Session flush is triggered in beforeCompletion.

      Then more changes are flushed to the database, but I run in a reproduceable database locking problem.

      After some time an update of a row fails with lock wait timeout. This row has been inserted prior during the EJB call.

      There should be exactly one xa transaction active processing all data changes.
      But the database shows two active session, one is an xa transaction with sessionId -2 (orphaned), the other session is a local transaction.

      After analyzing all database communication with the help of the JDBC driver logging I found the following behaviour:

      • a connection is enlisted and xa start called
      • the same connection is used for several select / insert / update statements
      • after return of the top EJB call on the same connection xa end and connection un-enlist is called
      • the same connection is used for session flush (beforeCompletion) but with local transaction because the connection is no longer associated with the xa transaction, so locks can be expected.

      Shouldn't xa end be called AFTER beforeCompletion / session flush!?!


        1. persistence.xml
          6 kB
        2. server_MSSQL_Trace.log
          7.60 MB
        3. server.jca.log
          7.63 MB
        4. server-9.0.0.Alpha1-SNAPHOT.log
          19 kB
        5. server-9.0.0.Alpha1-SNAPHOT-trace.log
          6.01 MB
        6. server-all-traces-full.log.gz
          7.06 MB
        7. server-org-jboss-as-jpa.log
          1.22 MB

        Issue Links


            Public project attachment banner

              context keys: [headless, issue, helper, isAsynchronousRequest, project, action, user]
              current Project key: WFLY


                thjenkin@redhat.com Tom Jenkinson
                mobilexagmuc Andreas Liebscher (Inactive)
                4 Vote for this issue
                10 Start watching this issue