6 Replies Latest reply on Jul 30, 2009 7:38 PM by yukon

    Concurrency Problem

    Eric Wang Newbie

      Hi guys,

      I am a poor java developer... and I'm on my way pushing myself to learn more.

      I met a problem when I use jBPM4.0CR1.

      The problem is described as following,

      My boss asked me to make a workflow, which mainly contains 2 concurrency flows. And unfortunately, one is contained in another...
      That means, a super process has a 'Con1' fork activity. And among the executions under that 'Con1', there is a sub-process, which also contains another fork activity 'Con2'.

      Here is jpdls, (concurrency.jpdl.xml & sub_concurrency.jpdl.xml)
      I hope you will understand what I am talking about~

      concurrency.jpdl.xml

      <process name="concurruncy" xmlns="http://jbpm.org/4.0/jpdl">
       <start g="13,103,48,48" name="start1">
       <transition g="-52,-22" name="to fork1" to="fork1"/>
       </start>
       <end g="818,27,48,48" name="end1"/>
       <fork g="100,101,48,48" name="fork1">
       <transition g="-52,-22" name="to task1" to="task1"/>
       <transition name="to task2" to="task2" g="-52,-22"/>
       </fork>
       <task assignee="#{u1}" g="240,145,92,52" name="task1">
       <transition g="-56,-21" name="to Subprocess1" to="Subprocess1"/>
       </task>
       <task assignee="#{u2}" g="223,12,92,52" name="task2">
       <transition g="-49,-22" name="to join2" to="join2"/>
       </task>
       <join g="681,26,48,48" name="join2">
       <transition g="-50,-22" name="to end1" to="end1"/>
       </join>
       <sub-process g="420,139,92,52" name="Subprocess1" sub-process-key="sub_concurrency">
       <parameter-in subvar="u2" var="u2"/>
       <parameter-in subvar="u4" var="u4"/>
       <transition g="-49,-22" name="to join2" to="join2"/>
       </sub-process>
      </process>
      


      sub_concurrency.jpdl.xml
      <process name="sub_concurrency" xmlns="http://jbpm.org/4.0/jpdl">
       <start g="89,110,48,48" name="start1">
       <transition g="-52,-22" name="to fork1" to="fork1"/>
       </start>
       <end g="596,115,48,48" name="sub_end"/>
       <fork g="200,107,48,48" name="fork1">
       <transition g="-52,-22" name="to task4" to="task4"/>
       <transition name="to task3" to="task3" g="-52,-22"/>
       </fork>
       <task assignee="#{u3}" g="304,60,92,52" name="task3">
       <transition g="-28,-25" name="to sub_join" to="sub_join"/>
       </task>
       <task assignee="#{u4}" g="309,150,92,52" name="task4">
       <transition g="-27,3" name="to sub_join" to="sub_join"/>
       </task>
       <join g="483,113,48,48" name="sub_join">
       <transition g="-36,-25" name="to sub_end" to="sub_end"/>
       </join>
      </process>
      


      I'm sorry. I apply these nonsense names on assignees and task names :)

      I make a JUnit test to run this work flow.
      Then, java exceptions appears,



      10:46:30,185 FIN | [Execution] execution[to task4] ends
      10:46:30,187 FIN | [Execution] execution[to task3] ends
      10:46:30,187 FIN | [ExecuteActivity] executing activity(sub_end)
      10:46:30,188 FIN | [Execution] process-instance ends with state ended
      10:46:30,203 FIN | [Signal] execution[to task1] signals activity(Subprocess1)
      10:46:30,204 WRN | [ProxyWarnLog] Narrowing proxy to class org.jbpm.jpdl.internal.model.JpdlExecution - this operation breaks ==
      10:46:30,204 FIN | [ExecuteActivity] execution[to task1] executes activity(join2)
      10:46:30,213 FIN | [Execution] execution[to task1] ends
      10:46:30,215 FIN | [Execution] execution[to task2] ends
      10:46:30,215 FIN | [ExecuteActivity] executing activity(end1)
      10:46:30,215 FIN | [Execution] process-instance ends with state ended
      10:46:30,228 WRN | [JDBCExceptionReporter] SQL Error: 1451, SQLState: 23000
      10:46:30,229 SEV | [JDBCExceptionReporter] Cannot delete or update a parent row: a foreign key constraint fails (`jbpm4db/jbpm4_execution`, CONSTRAINT `FK_EXEC_SUPEREXEC` FOREIGN KEY (`SUPEREXEC_`) REFERENCES `jbpm4_execution` (`DBID_`))
      ### EXCEPTION ###########################################
      10:46:30,229 SEV | [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.jpdl.internal.model.JpdlExecution#2]
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
       at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2569)
       at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2725)
       at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:172)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
       at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
       at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
       at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1141)
       at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
       at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)
       at org.jbpm.pvm.internal.hibernate.DbSessionImpl.findProcessInstanceById(DbSessionImpl.java:175)
       at org.jbpm.pvm.internal.hibernate.DbSessionImpl.deleteProcessInstance(DbSessionImpl.java:225)
       at org.jbpm.pvm.internal.model.ExecutionImpl.end(ExecutionImpl.java:354)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
       at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_3.end(ExecutionImpl_$$_javassist_3.java)
       at org.jbpm.pvm.internal.model.ExecutionImpl.end(ExecutionImpl.java:364)
       at org.jbpm.jpdl.internal.activity.EndActivity.execute(EndActivity.java:82)
       at org.jbpm.jpdl.internal.activity.EndActivity.execute(EndActivity.java:45)
       at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60)
       at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:625)
       at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:535)
       at org.jbpm.pvm.internal.model.ExecutionImpl.take(ExecutionImpl.java:441)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
       at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_3.take(ExecutionImpl_$$_javassist_3.java)
      


      I find that all the execution has been well finished and inactive executions will be deleted from jbpm4_exection

      10:53:39,305 FIN | [ExecuteActivity] execution[to task1] executes activity(join2)
      10:53:39,311 FIN | [Execution] execution[to task1] ends
      10:53:39,314 FIN | [Execution] execution[to task2] ends
      10:53:39,314 FIN | [ExecuteActivity] executing activity(end1)
      10:53:39,314 FIN | [Execution] process-instance ends with state ended
      


      But failed because of foreign key constraint. I dont know why...

      Do I make the problem clearly described?

      Please help me~ Thx!


      My mail: crazydog.eric@gmail.com
      -----------------------------------------------------
      And I find that if I add a state activity just after sub-process, which will join together with task2, things go right! Is it a kind of answer?


        • 1. Re: Concurrency Problem
          Eric Wang Newbie

          It's me again...

          I will post data generated by jBPM in MySQL just after exceptions occur

          SQL

          SELECT * FROM jbpm4_execution\G;
          


          Data in jbpm4_execution
          *************************** 1. row ***************************
           DBID_: 1
           CLASS_: jpdl
           DBVERSION_: 1
           ACTIVITYNAME_: NULL
           PROCDEFID_: concurruncy-1
           HASVARS_:
           NAME_: NULL
           KEY_: NULL
           ID_: concurruncy.1
           STATE_: inactive-concurrent-root
          SUSPHISTSTATE_: NULL
           PRIORITY_: 0
           HISACTINST_: NULL
           PARENT_: NULL
           INSTANCE_: 1
           SUPEREXEC_: NULL
           SUBPROCINST_: NULL
           PARENT_IDX_: NULL
          *************************** 2. row ***************************
           DBID_: 2
           CLASS_: jpdl
           DBVERSION_: 1
           ACTIVITYNAME_: Subprocess1
           PROCDEFID_: concurruncy-1
           HASVARS_:
           NAME_: to task1
           KEY_: NULL
           ID_: concurruncy.1.to task1[0]
           STATE_: active-concurrent
          SUSPHISTSTATE_: NULL
           PRIORITY_: 0
           HISACTINST_: 1
           PARENT_: 1
           INSTANCE_: 1
           SUPEREXEC_: NULL
           SUBPROCINST_: 4
           PARENT_IDX_: 0
          *************************** 3. row ***************************
           DBID_: 3
           CLASS_: jpdl
           DBVERSION_: 1
           ACTIVITYNAME_: join2
           PROCDEFID_: concurruncy-1
           HASVARS_:
           NAME_: to task2
           KEY_: NULL
           ID_: concurruncy.1.to task2[0]
           STATE_: inactive-join
          SUSPHISTSTATE_: NULL
           PRIORITY_: 0
           HISACTINST_: 2
           PARENT_: 1
           INSTANCE_: 1
           SUPEREXEC_: NULL
           SUBPROCINST_: NULL
           PARENT_IDX_: 1
          *************************** 4. row ***************************
           DBID_: 4
           CLASS_: jpdl
           DBVERSION_: 1
           ACTIVITYNAME_: NULL
           PROCDEFID_: sub_concurrency-1
           HASVARS_:
           NAME_: NULL
           KEY_: NULL
           ID_: sub_concurrency.4
           STATE_: inactive-concurrent-root
          SUSPHISTSTATE_: NULL
           PRIORITY_: 0
           HISACTINST_: NULL
           PARENT_: NULL
           INSTANCE_: 4
           SUPEREXEC_: 2
           SUBPROCINST_: NULL
           PARENT_IDX_: NULL
          *************************** 5. row ***************************
           DBID_: 5
           CLASS_: jpdl
           DBVERSION_: 1
           ACTIVITYNAME_: sub_join
           PROCDEFID_: sub_concurrency-1
           HASVARS_:
           NAME_: to task4
           KEY_: NULL
           ID_: sub_concurrency.4.to task4[0]
           STATE_: inactive-join
          SUSPHISTSTATE_: NULL
           PRIORITY_: 0
           HISACTINST_: 3
           PARENT_: 4
           INSTANCE_: 4
           SUPEREXEC_: NULL
           SUBPROCINST_: NULL
           PARENT_IDX_: 0
          *************************** 6. row ***************************
           DBID_: 6
           CLASS_: jpdl
           DBVERSION_: 0
           ACTIVITYNAME_: task3
           PROCDEFID_: sub_concurrency-1
           HASVARS_:
           NAME_: to task3
           KEY_: NULL
           ID_: sub_concurrency.4.to task3[0]
           STATE_: active-concurrent
          SUSPHISTSTATE_: NULL
           PRIORITY_: 0
           HISACTINST_: 4
           PARENT_: 4
           INSTANCE_: 4
           SUPEREXEC_: NULL
           SUBPROCINST_: NULL
           PARENT_IDX_: 1
          6 rows in set (0.00 sec)
          


          Look at row 4. Its SUPEREXEC_ refers to row2(DBID_=2)

          • 2. Re: Concurrency Problem
            Ronald van Kuijk Master

            sorry, this is not directed at you peronally but DOES ANYBODY EVER USE SOME KIND OF SEARCH FUNCTIONALITY?

            The post below yours is about EXACTELY this same Error

            • 4. Re: Concurrency Problem
              Eric Wang Newbie

              hi kukeltje,

              very appreciate your replies!

              I'm a new one here. And I even don't know JIRA... What a pity!

              I go through the topic you have metioned

              http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4238433#4238433

              If I don't misunderstand that post, changing org.hibernate.dialect can get my problem solved?

              However, my org.hibernate.dialect is configured as org.hibernate.dialect.MySQLInnoDBDialect...

              <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
              <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
              <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpm4db</property>
              <property name="hibernate.connection.username">root</property>
              <property name="hibernate.connection.password">123456</property>
              <property name="hibernate.hbm2ddl.auto">update</property>
              <property name="hibernate.show.sql">true</property>
              
              <mapping resource="jbpm.repository.hbm.xml" />
              <mapping resource="jbpm.execution.hbm.xml" />
              <mapping resource="jbpm.history.hbm.xml" />
              <mapping resource="jbpm.task.hbm.xml" />
              <mapping resource="jbpm.jpdl.hbm.xml" />
              <mapping resource="jbpm.identity.hbm.xml" />


              So I think my problem is different from that. ?



              And the ConstraintViolationException
              here is because `FK_EXEC_SUPEREXEC` but not `FK_EXEC_INSTANCE` (Yes, it's due to that I use sub-process. Because if I put these 2 fork flows into One process, one embedded into another, tasks in Inner-Fork-Flow will be created twice)



              This time I try to be clever to USE SOME KIND OF SEARCH FUNCTIONALITY (I was stupid enough yesterday~~). I learn Google! hahaha

              Fortunately, I find this issue list

              https://jira.jboss.org/jira/secure/BrowseVersion.jspa?id=10052&versionId=12313199&showOpenIssuesOnly=true (And I know JIRA! Fortunately again)



              And I find this issue JBPM-2303 UNRESOLVED Exception with a process containing a fork/join

              You can touch it:https://jira.jboss.org/jira/browse/JBPM-2303

              I ran that tests and got exceptions. I think join/fork flow has its own bugs.



              I should go to see what happens in jBPM4. I should have enough time to do that. It's my fault.

              I really want to know what's wrong with my code, What is the actual reason caused that exception happens. If it is proved to be a bug, I can sleep well tonight~~ hahaha



              Please help me again. Thx!

              Or I have to wait for jBPM4 released? hahahaha

              My e-mail: crazydog.eric@gmail.com



              • 5. Re: Concurrency Problem
                Ronald van Kuijk Master

                And maybe this as well

                • 6. Re: Concurrency Problem
                  yukon Newbie

                  Did you find the solution for this issue. I am having the same problem.

                  Thanks
                  Yo