2

I have a web app that is deployed in a load balanced environment on multiple physical instances. All the instances talk to the same database.

I have a transaction that can be triggered from the gui, I want to make sure that if this operation is requested simultaneously, either accross VM's or on the same VM. That only one transaction succeeds or that the transactions are serialized.

I'm using Hibernate 3.6, Spring 3.1 and JPA2 ( jar incl. with Hibernate).

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE, rollbackFor = LockTimeoutException.class)
public boolean MY_OP(Boolean Flag) throws RuntimeException

I'm trying to use the solution described here and here.

My configuration is listed here:

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="DB_UNIT_NAME" />
    <property name="dataSource" ref="dataSource" />
  <property name="jpaDialect">
     <bean class="com.server.persistence.HibernateExtendedJpaDialect"/>
  </property>
  <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true" />
        <property name="generateDdl" value="true" />
            <property name="databasePlatform" value="${dbConfig.dialect}" />
        </bean>
    </property>
</bean>

<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>

<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

Would this achieve isolation across multiple JVM's in load balanced environments? I'm sure people must have solved this problem before, so any ideas would be helpful.

EDIT

This achieves isolation on a single JVM/AS. I'm using JBoss AS 4.3.2 (yes, I know its old).

Community
  • 1
  • 1
Asif Mohammed
  • 790
  • 4
  • 11
  • 25

1 Answers1

0

What is your problem exactly? Are you having deadlocks? Stacks?

Because it's kind of "normal" to have such troubles with the isolation level you choose and some concurrency.

Do you really need that isolation level?

Are your doing bulk updates?

Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
  • i want to ensure that no two instances of MY-TRANSACTION whether they be initiated on the same JVM/AS or multiple ones concurrently, only one of them should run and others should fail. I'm fairly new to working with isolation levels so not sure if this is the right level. But i think the solution in the posted question seems to achieve this from what i can tell, i was wondering this was the correct way to approach this issue. – Asif Mohammed Mar 01 '12 at 00:23
  • yes it should, but remember that you'll probably get many transaction exceptions when dealing with concurrency. Do load tests with that isolation level and check everything is fine – Sebastien Lorber Mar 01 '12 at 09:23