1 Reply Latest reply on Apr 2, 2007 9:33 AM by Kevin Conner

    JBossCache concurrent transaction management

    andrea ricci Newbie

      Hi everyone,
      i am trying to understand how concurrent transactions are managed by JBossCache. I have developed a simple EJB3 application that i am testing on a cluster of JBoss-4.0.5 instances. it creates a certain amount of threads that perform concurrent modification and creation of EntityBeans on different nodes of the cluster, sharing a common DB (PostgreSQL-8.2.1).

      my JBossCache (version1.4.0.SP1) EntityBeans configuration is:
      - NodeLockingScheme: PESSIMISTIC
      - IsolationLevel: REPEATABLE_READ
      - CacheMode: REPL_SYNC

      several scenarios have arised when two transactions try to concurrently create the same EntityBean on different nodes of the cluster:

      1) sometimes they stop their execution till a timeout expire (ERROR [IdentityLock] write lock for /server/Book/server.Book#4 could not be acquired after 15000 ms), when one of them is able to committ its transaction. it looks like both are waiting the other to acquire lock: a deadlock that is broken only when timeout exception arises.

      2) sometimes one of them is aborted because of duplicate key violation (ERROR: duplicate key violates unique constraint "book_pkey". ERROR [JDBCExceptionReporter] Batch entry 0 insert into BOOK (TITLE, AUTHOR, ID) values (Fiesta, Hernest Hemingway, 5) was aborted. Call getNextException to see the cause.).

      3) sometimes one of them is aborted beacuse of PersistenceException (ERROR: PersistenceException, org.hibernate.PersistentObjectException: detached entity passed to persist: server.Book).

      what i don´t understand is:
      - why exception (1) arises?
      - what is the difference between exception (2) and (3)? is that in exception (2) transaction is aborted at DB level, when performing INSERT operation, instead in exception (3) it is aborted at AS level, when creating the EntityBean?

      finally i would like to know if it exists a document where it is deeply described how transactions are managed by JBossCache inside a cluster.

      many thanks
      Andrea