Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2715

JDBCAppender commits to the DB a JTA RollbackOnly transaction and causes DB inconsistency

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.9.1, 2.12.1
    • 2.17.2
    • Appenders, JDBC
    • None
    • Container Payara 5.183,

      Application: EAR using EJB 3, Hibernate 5.3.6-FINAL

      JDBC Driver: Oracle Driver ojdbc8

    • Important

    Description

      I'm using log4j2 in a Payara 5.183 server and I've enabled a JDBC Appender connected to a JNDI datasource.

      <JDBC name="DBAppender" tableName="LOG_TABLE">
          <DataSource jndiName="myJNDI"></DataSource>
          <Column ..." />   

           <Column ..." />

      </JDBC>

      The same datasource is used by the application to talk with the db. If the application, that uses EJB3, marks the transaction to be rolled back (sessionContext.setRollbackOnly()), each statement sent to the database (flush(), executeUpdate()) inside the transaction must not be committed.

      What happens is that using the jdbc appender causes a commit that writes to the database everything, causing database inconsistency.

      Using DriverManager instead of a JNDI works fine, but I don't know if I can set a connection pool with it.

       

      When log4j is inside a JTA transaction it should use another JDBC connection to log.

       

       

       

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            davidobber David Obber
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: