-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Default transaction timeout is killing transactions randomly
PostPosted: Mon Feb 24, 2014 7:46 am 
Newbie

Joined: Mon Feb 24, 2014 5:32 am
Posts: 1
After setting the default transaction timeout on my JPATransactionManager to ensure any blocked transactions get killed, I have noticed some transactions being killed immediately as soon as they start. It doesn't always happen, just for some of them.

It appears as though the transaction timeout deadline is sometimes being inherited from a previous transaction, or is not being independently set.
e.g. in the case below, the previous transaction started at 19.09, with a timeout of 30 mins. It completed successfully. But at 7.00 next morning a timed job kicks off (in a new transaction), and fails immediately stating that the timeout deadline of 19.39 has passed.

2014-02-20 07:00:12.602Z ERROR Transaction timed out: deadline was Wed Feb 19 19:39:45 UTC 2014
INFO | jvm 1 | 2014/02/20 07:00:12 | org.springframework.transaction.TransactionTimedOutException: Transaction timed out: deadline was Wed Feb 19 19:39:45 UTC 2014
INFO | jvm 1 | 2014/02/20 07:00:12 | at org.springframework.transaction.support.ResourceHolderSupport.checkTransactionTimeout(ResourceHolderSupport.java:141) ~[spring-tx-3.1.1.RELEASE.jar:3.1.1.RELEASE]

Is there a property I am missing, or a known bug?

I suspected not releasing the session might be an issue so I tried adding what hibernate properties looked relevant on the entity manager factory but they made no difference (and I think should be default behaviour anyway?)

Config:

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() throws SQLException
{
final LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
bean.setDataSource(dataSource());
bean.setJpaDialect(new HibernateJpaDialect());

final Map<String, String> jpaPropertyMap = new HashMap<String, String>();
jpaPropertyMap.put("hibernate.connection.release_mode", "after_transaction");
jpaPropertyMap.put("hibernate.current_session_context_class", "thread");

bean.setJpaPropertyMap(jpaPropertyMap);
bean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
return bean;
}

@Bean
public PlatformTransactionManager transactionManager() throws SQLException
{
JpaTransactionManager transactionManager = new JpaTransactionManager(entityManagerFactoryBean().getObject());
transactionManager.setDefaultTimeout(transactionTimeoutSeconds);

return transactionManager;
}

Thx for any help,
Mark


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.