You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2019/10/24 23:01:00 UTC

[jira] [Commented] (LOG4J2-2715) JDBCAppender commits to the DB a JTA RollbackOnly transaction and causes DB inconsistency

    [ https://issues.apache.org/jira/browse/LOG4J2-2715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16959280#comment-16959280 ] 

Gary D. Gregory commented on LOG4J2-2715:
-----------------------------------------

Log4j expects to NOT share its JDBC Connections to the database with other components, that's a recipe for disaster.

> JDBCAppender commits to the DB a JTA RollbackOnly transaction and causes DB inconsistency
> -----------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2715
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2715
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders, JDBC
>    Affects Versions: 2.9.1, 2.12.1
>         Environment: Container Payara 5.183,
> Application: EAR using EJB 3, Hibernate 5.3.6-FINAL
> JDBC Driver: Oracle Driver ojdbc8
>            Reporter: David Obber
>            Priority: Critical
>
> 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 *{color:#de350b}writes to the database everything{color}*, *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.
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)