SQLException Transaction Status Rollback in WrapperDataSource without any notice
siggi-k. Dec 14, 2017 4:15 PMWe are migrating from JBoss 4.2.3 GA and MS SQL Server 2008 R2 to Wildfly 11 and PostgreSQL 10. We use the Hibernate version shipped with Wildfly (5.1.10.Final)
We have a very complex application where we use an external API that cannot be debugged by myself. We are using EJB remote proxies of this API for executing operations.
There are several DB-Operations executed with JPA (NamedQuery on an Entity) in one container managed transaction (xa-datasource configured in Wildfly 11).
The NamedQuery works fine for most cases, but there's one case an error occurs without any visible notice in the logfiles.
The transaction is marked with status rollback, but I don't have any idea why. No exception, no debug message, nothing.
The only difference to the same NamedQuery in this scenario is that rows are deleted from the tables a few steps before within the same transaction.
We already had some problems with PostgreSQL and our application as PostgreSQL does not implement standard transaction isolation level "read uncommited" as the MS SQL Server does, see https://www.postgresql.org/docs/10/static/transaction-iso.html
I don't know if this may be related to my problem.
The only guess I have right now is an error and supressed exception in the external API, e. g. locking.
This is the relevant Stacktrace where Hibernate fails to prepare the statement:
Caused by: org.hibernate.exception.GenericJDBCException: could not prepare statement at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1934) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1903) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1881) at org.hibernate.loader.Loader.doQuery(Loader.java:925) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342) at org.hibernate.loader.Loader.doList(Loader.java:2622) at org.hibernate.loader.Loader.doList(Loader.java:2605) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2434) at org.hibernate.loader.Loader.list(Loader.java:2429) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1339) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483) ... 172 more
Caused by: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_MARKED_ROLLBACK at org.jboss.jca.adapters.jdbc.WrapperDataSource.checkTransactionActive(WrapperDataSource.java:245) at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransactionActive(WrappedConnection.java:1928) at org.jboss.jca.adapters.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:1943) at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1917) at org.jboss.jca.adapters.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:447) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172) ... 189 more
I set the log level of nearly anything to debug/trace, switched on Spy (as mentioned in the IronJacamar documentation).
The last thing printed with level debug is "getConnection()" and the prepared statement from Hibernate, which is executable via pgadmin.
Does anyone have an idea what may cause such an error without any further notice?
Siggi