Atomikos Forum |
|
Hi. Last night I got an HeuristicMixedException in my production code and since then, each and every transaction fails to commit.
This is the trace: ####################### 05 06 2009 06:27:44 ERROR TP-Processor131 net.sf.hibernate.transaction.JTATransaction - Commit failed javax.transaction.HeuristicMixedException: Heuristic Exception at com.atomikos.icatch.jta.TransactionImp.commit(Unknown Source) at com.atomikos.icatch.jta.TransactionManagerImp.commit(Unknown Source) at com.atomikos.icatch.jta.UserTransactionImp.commit(Unknown Source) at net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:56) ####################### My setup is as follows: Atomikos Transactions Essentials 3.3.1 Hibernate 2.1.7 Two PostgreSQL 8.2.6 datasources Tomcat 5.5.26 I haven't found much on Google about this Exception. Could someone please tell me under which circumstances this exception could happen? Thanks in advance
I'll add more info, in case it matters.
This is how I declare my datasources in Tomcat: ####################### <Resource name="jdbc/frontinteco" auth="Container" type="com.atomikos.jdbc.AtomikosDataSourceBean" factory="com.atomikos.tomcat.BeanFactory" uniqueResourceName="jdbc/front" xaDataSourceClassName="org.postgresql.xa.PGXADataSource" maxPoolSize="100" minPoolSize="1" reapTimeout="-1" borrowConnectionTimeout="300" maxIdleTime="600" maintenanceInterval="300" xaProperties.user="test" xaProperties.password="test" xaProperties.serverName="172.16.178.84" xaProperties.portNumber="5432" xaProperties.databaseName="myddbb" /> ####################### I have this on my Tomcat context.xml: <Transaction factory="com.atomikos.icatch.jta.UserTransactionFactory" /> And this on my hibernate configuration: ####################### <property name="jta.UserTransaction">java:comp/UserTransaction</property> <property name="hibernate.transaction.factory_class">my.persistence.JTATransactionFactory</property> <property name="hibernate.transaction.manager_lookup_class">my.hibernate.TransactionManagerLookup</property> ####################### my.persistence.JTATransactionFactory looks like this: ####################### private static final Log log = LogFactory.getLog(JTATransactionFactory.class); private static final String DEFAULT_USER_TRANSACTION_NAME = "java:comp/UserTransaction"; private InitialContext context; private String utName; private TransactionManager transactionManager; public void configure(Properties props) throws HibernateException { try { context = NamingHelper.getInitialContext(props); } catch (NamingException ne) { log.error("Could not obtain initial context", ne); throw new HibernateException( "Could not obtain initial context", ne ); } utName = props.getProperty(Environment.USER_TRANSACTION); TransactionManagerLookup lookup = TransactionManagerLookupFactory.getTransactionManagerLookup(props); if (lookup!=null) { transactionManager = lookup.getTransactionManager(props); if (utName==null) utName = lookup.getUserTransactionName(); } if (utName==null) utName = DEFAULT_USER_TRANSACTION_NAME; } public Transaction beginTransaction(SessionImplementor session) throws HibernateException { JTATransaction tx = new JTATransaction(session); tx.begin(context, utName, transactionManager); return tx; } ####################### And my.hibernate.TransactionManagerLookup like this: ####################### public class TransactionManagerLookup implements net.sf.hibernate.transaction.TransactionManagerLookup { private static final String TIMEOUT = ApplicationPropertiesManager.getInstance().getProperty("transaction.timeout"); private UserTransactionManager utm; public TransactionManagerLookup() { utm = new UserTransactionManager(); if (TIMEOUT != null) { try { utm.setTransactionTimeout(Integer.parseInt(TIMEOUT)); } catch (SystemException e) { throw new RuntimeException(e); } } } public TransactionManager getTransactionManager(Properties properties) throws HibernateException { return utm; } public String getUserTransactionName() { return null; } } #######################
My jta.properties:
##################### com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory com.atomikos.icatch.console_file_limit=10000 com.atomikos.icatch.console_file_count=10 com.atomikos.icatch.output_dir=/opt/tomcat/tomcat/temp com.atomikos.icatch.log_base_dir=/opt/tomcat/tomcat/temp com.atomikos.icatch.max_timeout = 300000 com.atomikos.icatch.console_log_level=INFO com.atomikos.icatch.force_shutdown_on_vm_exit=true com.atomikos.icatch.lock_logs=false #####################
OK, it seems we've found the problem. PostgreSQL was complaining that the configured maximum number of prepared transactions had been reached. We had set the max_prepared_transactions pararameter to 10 while the max_connections was 300, and, as per the PostgreSQL docs, max_prepared_transactions should be at least as big as max_connections.
|