[jboss-user] [JBoss Cache: Core Edition] - addNewSubtree method is not thread safe

nimrod.gat do-not-reply at jboss.com
Thu Aug 28 12:40:12 EDT 2008


I'm using JBoss cache 2.0.0.GA with multiple threads caching process.
Sometimes, at the beginning of the process, the unique constraint of the table is violated even though each thread uses a unique id (log attached).

Ive noticed that the first node added to the tree is the one creating the root node using addNewSubtree method which called from _put method, but the lock acquired in _put  is from StripedLock which  is FQN based lock what causing two different nodes to create the root node at the same time.

StripedLock doesn't enough when creating the root node.

a workaround is to create "dummy" node before multiple thread cache process.


2008-08-11 02:26:53,698 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple at 1befb76d
  | java.lang.IllegalStateException: Failed to insert node: ORA-00001: unique constraint (PFIZERMM2_4_HILLEL.JBOSSCACHE_APPLICATION_PK) violated
  | 
  | 	at org.jboss.cache.loader.AdjListJDBCCacheLoader.insertNode(AdjListJDBCCacheLoader.java:490)
  | 	at org.jboss.cache.loader.JDBCCacheLoader.addNewSubtree(JDBCCacheLoader.java:220)
  | 	at org.jboss.cache.loader.JDBCCacheLoader._put(JDBCCacheLoader.java:188)
  | 	at org.jboss.cache.loader.JDBCCacheLoader.put(JDBCCacheLoader.java:79)
  | 	at org.jboss.cache.loader.AbstractCacheLoader.put(AbstractCacheLoader.java:233)
  | 	at org.jboss.cache.loader.AdjListJDBCCacheLoader.prepare(AdjListJDBCCacheLoader.java:189)
  | 	at org.jboss.cache.interceptors.CacheStoreInterceptor.prepareCacheLoader(CacheStoreInterceptor.java:330)
  | 	at org.jboss.cache.interceptors.CacheStoreInterceptor.invoke(CacheStoreInterceptor.java:144)
  | 	at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
  | 	at org.jboss.cache.interceptors.CacheLoaderInterceptor.invoke(CacheLoaderInterceptor.java:160)
  | 	at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
  | 	at org.jboss.cache.interceptors.UnlockInterceptor.invoke(UnlockInterceptor.java:37)
  | 	at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
  | 	at org.jboss.cache.interceptors.PessimisticLockInterceptor.invoke(PessimisticLockInterceptor.java:203)
  | 	at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
  | 	at org.jboss.cache.interceptors.NotificationInterceptor.invoke(NotificationInterceptor.java:32)
  | 	at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
  | 	at org.jboss.cache.interceptors.TxInterceptor.runPreparePhase(TxInterceptor.java:833)
  | 	at org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler.beforeCompletion(TxInterceptor.java:1154)
  | 	at org.jboss.cache.interceptors.OrderedSynchronizationHandler.beforeCompletion(OrderedSynchronizationHandler.java:84)
  | 	at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
  | 	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
  | 	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
  | 	at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
  | 	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)
  | 	at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
  | 	at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
  | 	at org.jboss.resource.adapter.jms.inflow.JmsServerSession$XATransactionDemarcationStrategy.end(JmsServerSession.java:494)
  | 	at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:248)
  | 	at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
  | 	at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
  | 	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
  | 	at java.lang.Thread.run(Thread.java:619)
  | Caused by: java.sql.SQLException: ORA-00001: unique constraint (PFIZERMM2_4_HILLEL.JBOSSCACHE_APPLICATION_PK) violated
  | 
  | 	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
  | 	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
  | 	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
  | 	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:626)
  | 	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:182)
  | 	at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:630)
  | 	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1081)
  | 	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2905)
  | 	at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2977)
  | 	at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
  | 	at org.jboss.cache.loader.AdjListJDBCCacheLoader.insertNode(AdjListJDBCCacheLoader.java:477)
  | 	... 32 more

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4173132#4173132

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4173132



More information about the jboss-user mailing list