[jboss-user] [jBPM] - jBPM session persistence - "Removing a detached instance" encountered under load / concurrency

Mark Egan do-not-reply at jboss.com
Wed Nov 28 14:06:03 EST 2012


Mark Egan [https://community.jboss.org/people/xmrk] created the discussion

"jBPM session persistence - "Removing a detached instance" encountered under load / concurrency"

To view the discussion, visit: https://community.jboss.org/message/778981#778981

--------------------------------------------------------------
I'm encountering an exception with jbpm-persistence-jpa when performing load testing on an application-embedded jBPM.  The stack trace is:

Caused by: java.lang.IllegalArgumentException: Removing a detached instance org.drools.persistence.info.WorkItemInfo#234
     at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventListener.java:67) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
     at org.hibernate.event.internal.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:107) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
     at org.hibernate.event.internal.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:74) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
     at org.hibernate.internal.SessionImpl.fireDelete(SessionImpl.java:822) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
     at org.hibernate.internal.SessionImpl.delete(SessionImpl.java:801) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
     at org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:883) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
     at org.drools.persistence.jpa.JpaPersistenceContext.remove(JpaPersistenceContext.java:54) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]
     at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:123) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

I'm using 5.4.0.Final (however I observed the same behavior in 5.3.0.Final and 5.4.0.CR1).  The application server is JBoss AS 7.  I'm using MySQL InnoDB having row-locking enabled.

The process calls EJBs within separate WorkItemHandlers.  Here's the basic process:

1) start process,
2) call a local, no-interface EJB (injected with @Inject) and persist a domain object (using a separate persistence context),
3) lookup another EJB (using InitialContext.doLookup) and perform some synchorous work,
4) end process.

I'm initiating the process from a REST endpoint.  The jBPM session.startProcess(...) occurs in a Local EJB exposed service.

The load test calls the REST endpoint.  I'm using jMeter.  The thread group only consists of 2 threads.  There is a short ramp-up.

Here's a rundown of my observations:

During ramp-up where the process service is a single thread, no issues are observed.  Once the second thread spins up, the exception is received on all subsequent calls.  The WorkItemInfo which fails to be removed is for step #2 (the local EJB call to a separate persistence service).  If I remove the third step from the definition, the issue is not observed.

Here's my Environment for the JPAKnowledgeService.newStatefulKnowledgeSession(...).  

@Produces
public Environment getEnvironment() {
    Environment env = KnowledgeBaseFactory.newEnvironment();
    env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
    env.set(EnvironmentName.TRANSACTION_MANAGER, new ContainerManagedTransactionManager());
    env.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, new JpaProcessPersistenceContextManager(env));
    return env;
}

I'm only using a session once and dispose of it after a single process completes.

I'm setting the following for my persistence context:
hibernate.transaction.factory_class=org.hibernate.transaction.CMTTransactionFactory

I understand that what I'm encountering could be related to general container handled transactions across my EJB calls, but I wanted to start with the jBPM community.  I had already investigated the transaction handling on those EJB calls and wasn't able to resolve the issue using various @TransactionAttribute or alterations to the persistence context's properties.

I also reviewed the persistence chapter in the 5.4 User Guide:  http://docs.jboss.org/jbpm/v5.4/userguide/ch.core-persistence.html http://docs.jboss.org/jbpm/v5.4/userguide/ch.core-persistence.html, as well as the Multi-Threading section:  http://docs.jboss.org/jbpm/v5.4/userguide/ch.core-basics.html#d0e2358 http://docs.jboss.org/jbpm/v5.4/userguide/ch.core-basics.html#d0e2358.

Any help is appreciated.

Thanks,
-mark
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/778981#778981]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121128/26411a36/attachment.html 


More information about the jboss-user mailing list