<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Serious multithreading problem with embedded Activiti in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/serious-multithreading-problem-with-embedded-activiti/m-p/58761#M36016</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi guys!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are using Activiti in our project. It was a very good experience so far for the whole team, both the product and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the documentation was great.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Our application has a Spring 3 / Hibernate backend and we use the Activiti engine embedded into our Spring configuration.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The Spring integration looked pretty good throughout the development of the application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are just before the handover phase and we ran an internal performance test. It was quite shocking that the Activiti engine began to throw Database Deadlock exceptions with as few as 4 concurrent users. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We analyzed our code thoroughly, and replaced our initial database choice with several other databases but the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;problem remained.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We created a test case to separate our application logic from this weird multithreaded behaviour, and it show that in fact it is the Activiti engine that causes the deadlock. Our test case is pretty simple, a sequencial series of human tasks, service tasks and receive tasks (to force persistence in some cases). Our test code starts several threads to initialize one process instances per thread. A process variable is set prior to the start of the process that is used later in a boundary event (timer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The full source code and executable binaries (with all the dependencies) of the test case can be downloaded from &lt;/SPAN&gt;&lt;A href="http://www63.zippyshare.com/v/62854622/file.html" rel="nofollow noopener noreferrer"&gt;http://www63.zippyshare.com/v/62854622/file.html&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We would be keen to create a JIRA issue on this, and would be happy to be involved in the fix.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Lock aquisition exception occurs in the following scenario:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.insertExecution-Inline&lt;BR /&gt;### The error occurred while setting parameters&lt;BR /&gt;### Cause: org.hibernate.exception.LockAcquisitionException: Deadlock detected. The current transaction was rolled back. Details: "&lt;BR /&gt;Session #14 (user: SA) is waiting to lock PUBLIC.ACT_RU_VARIABLE while locking PUBLIC.ACT_RE_PROCDEF (shared), PUBLIC.ACT_RU_VARIABLE (shared), PUBLIC.ACT_RU_EXECUTION (exclusive).&lt;BR /&gt;Session #12 (user: SA) is waiting to lock PUBLIC.ACT_RU_EXECUTION while locking PUBLIC.ACT_RE_PROCDEF (shared), PUBLIC.ACT_RU_VARIABLE (shared)."; SQL statement:&lt;BR /&gt;insert into ACT_RU_EXECUTION (ID_, REV_, PROC_INST_ID_, BUSINESS_KEY_, PROC_DEF_ID_, ACT_ID_, IS_ACTIVE_, IS_CONCURRENT_, IS_SCOPE_, PARENT_ID_, SUPER_EXEC_)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; values (&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) [40001-158]&lt;BR /&gt; at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)&lt;BR /&gt; at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:120)&lt;BR /&gt; at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:107)&lt;BR /&gt; at org.activiti.engine.impl.db.DbSqlSession.flushInserts(DbSqlSession.java:410)&lt;BR /&gt; at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:337)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:147)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:103)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)&lt;BR /&gt; at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)&lt;BR /&gt; at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)&lt;BR /&gt; at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)&lt;BR /&gt; at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:49)&lt;BR /&gt; at hu.sonrisa.example.service.impl.WorkflowServiceImpl.startProcess(WorkflowServiceImpl.java:97)&lt;BR /&gt; at hu.sonrisa.example.ActivitiThread.run(ActivitiThread.java:64)&lt;BR /&gt; at java.lang.Thread.run(Thread.java:662)&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Jul 2011 09:30:13 GMT</pubDate>
    <dc:creator>gergelydombi</dc:creator>
    <dc:date>2011-07-21T09:30:13Z</dc:date>
    <item>
      <title>Serious multithreading problem with embedded Activiti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/serious-multithreading-problem-with-embedded-activiti/m-p/58761#M36016</link>
      <description>Hi guys!We are using Activiti in our project. It was a very good experience so far for the whole team, both the product andthe documentation was great.Our application has a Spring 3 / Hibernate backend and we use the Activiti engine embedded into our Spring configuration.The Spring integration looke</description>
      <pubDate>Thu, 21 Jul 2011 09:30:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/serious-multithreading-problem-with-embedded-activiti/m-p/58761#M36016</guid>
      <dc:creator>gergelydombi</dc:creator>
      <dc:date>2011-07-21T09:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Serious multithreading problem with embedded Activiti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/serious-multithreading-problem-with-embedded-activiti/m-p/58762#M36017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gergely,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Activiti comes with a (limited) set of indeces, mainly of FK's. If you do queries on e.g. process variables in your code, that can result in full table scans and locks. (See another post in the forum about jmeter tests). So analyzing that is what you should do first. For the other poster it prevented lots of issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason Activiti cannot (will not) provide all indeces, is that to many indeces slows the db down considerably. So They should be tuned to the specific usage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hth (to some extend)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2011 10:55:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/serious-multithreading-problem-with-embedded-activiti/m-p/58762#M36017</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2011-07-21T10:55:19Z</dc:date>
    </item>
  </channel>
</rss>

