<?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 Re: Async service task is tried to be run several times in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242346#M195476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Yes, but if you use asyncExecutor, it also puts this job into memory queue to reduce DB queries count for next step."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes - that is a good point and I am glad it does so.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Well, nearly… May be not thread from pool (I belive it's asyncExecutor main thread). And LOCK_TIME_ is set to current time, not to lock end. Also if it's exclusive job, process instance is locked similar to job lock. Note that here lock transaction is commited, that is update to lock time is put into DB immediately."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes - I agree it is the asyncExecutor thread but I have double checked the time on updates and it is not the current time. It already adds the 5 min to the current time and updates the record in DB. At least using version 5.21.0. As for locking the process instance - I have not checked it at all - will do shortly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"In case of several executors there are possible "normal" locking exceptions when they concurrently try to commit updated lock time. Winner locks job (and process), losers fall back and do other jobs."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That would make sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Well, nearly… Executor checks for LOCK_TIME_+asyncExecutorAsyncJobLockTimeInMillis comparing it to current time. If job is fetched from DB and got to execution, it's relocked, LOCK_TIME_ is undated."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well - I would understand to relock the job and LOCK_TIME_ is updated. But why to start the same task from scratch if it is already running ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"I'm not activiti developer, but logic is quite clear. Different activiti engines (in cluster, for example) do not communicate to each other, they can only synchronize through DB. It's possible to make sophisticated logic behind DB facade, but it's not transparent. So simple yet effective mechanics was used: commit lock time and check lock time + timeout.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There is no pings between engines that can tell other engines that current executor is still working on it. If your node takes job and loses intranet, power supply or simply sleeps for ages in web call, other nodes can still get this job… later."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My earlier question as to why to start again even if it is still running might be answered by your reply if it is indeed the reasons behind it (eg several engines running not knowing anything about each other). Still doesn't sound to me like a perfect solution but that might be the trade off to achieve the goal without complicating things …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks for your reply - much appreciated !&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Still keen to hear any other explanations - if there are any &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Adrian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Oct 2016 13:06:07 GMT</pubDate>
    <dc:creator>serid</dc:creator>
    <dc:date>2016-10-26T13:06:07Z</dc:date>
    <item>
      <title>Async service task is tried to be run several times</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242344#M195474</link>
      <description>Hi All,I noticed that if I have an async (exclusive) task (service task) which runs for a long time activiti tries to run it several times.So I tried to see what is happening and these are my guesses:1) When a task is defined as async and run, it adds records to act_ru_execution and act_ru_job table</description>
      <pubDate>Wed, 26 Oct 2016 11:15:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242344#M195474</guid>
      <dc:creator>serid</dc:creator>
      <dc:date>2016-10-26T11:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Async service task is tried to be run several times</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242345#M195475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Adrian!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;when a task is defined as async and is run, it adds an entry in act_ru_execution and act_ru_job.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, but if you use asyncExecutor, it also puts this job into memory queue to reduce DB queries count for next step.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;Then a thread from a pool picks it up and "locks" it by updating LOCK_TIME_ and DUEDATE_ ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, nearly… May be not thread from pool (I belive it's&amp;nbsp; asyncExecutor main thread). And LOCK_TIME_ is set to current time, not to lock end. Also if it's exclusive job, process instance is locked similar to job lock. Note that here lock transaction is commited, that is update to lock time is put into DB immediately.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In case of several executors there are possible "normal" locking exceptions when they concurrently try to commit updated lock time. Winner locks job (and process), losers fall back and do other jobs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;And if the task does not complete in that time it releases the lock (update again) so another thread can pick it up and start again ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, nearly… Executor checks for LOCK_TIME_+asyncExecutorAsyncJobLockTimeInMillis comparing it to current time. If job is fetched from DB and got to execution, it's relocked, LOCK_TIME_ is undated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;Why such behaviour&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not activiti developer, but logic is quite clear. Different activiti engines (in cluster, for example) do not communicate to each other, they can only synchronize through DB. It's possible to make sophisticated logic behind DB facade, but it's not transparent. So simple yet effective mechanics was used: commit lock time and check lock time + timeout.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There is no pings between engines that can tell other engines that current executor is still working on it. If your node takes job and loses intranet, power supply or simply sleeps for ages in web call, other nodes can still get this job… later.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;Basically I want to have the possibility to run either non async and async tasks only once until they finish / throw exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can set asyncExecutorAsyncJobLockTimeInMillis&amp;nbsp; and asyncExecutorTimedJobLockTimeInMillis to really high values (several days) and it will never happen again. You'll have to deal with jobs that were locked but never released though (for example, jobs running during server restart).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 12:49:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242345#M195475</guid>
      <dc:creator>warper</dc:creator>
      <dc:date>2016-10-26T12:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Async service task is tried to be run several times</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242346#M195476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Yes, but if you use asyncExecutor, it also puts this job into memory queue to reduce DB queries count for next step."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes - that is a good point and I am glad it does so.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Well, nearly… May be not thread from pool (I belive it's asyncExecutor main thread). And LOCK_TIME_ is set to current time, not to lock end. Also if it's exclusive job, process instance is locked similar to job lock. Note that here lock transaction is commited, that is update to lock time is put into DB immediately."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes - I agree it is the asyncExecutor thread but I have double checked the time on updates and it is not the current time. It already adds the 5 min to the current time and updates the record in DB. At least using version 5.21.0. As for locking the process instance - I have not checked it at all - will do shortly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"In case of several executors there are possible "normal" locking exceptions when they concurrently try to commit updated lock time. Winner locks job (and process), losers fall back and do other jobs."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That would make sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Well, nearly… Executor checks for LOCK_TIME_+asyncExecutorAsyncJobLockTimeInMillis comparing it to current time. If job is fetched from DB and got to execution, it's relocked, LOCK_TIME_ is undated."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well - I would understand to relock the job and LOCK_TIME_ is updated. But why to start the same task from scratch if it is already running ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"I'm not activiti developer, but logic is quite clear. Different activiti engines (in cluster, for example) do not communicate to each other, they can only synchronize through DB. It's possible to make sophisticated logic behind DB facade, but it's not transparent. So simple yet effective mechanics was used: commit lock time and check lock time + timeout.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There is no pings between engines that can tell other engines that current executor is still working on it. If your node takes job and loses intranet, power supply or simply sleeps for ages in web call, other nodes can still get this job… later."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My earlier question as to why to start again even if it is still running might be answered by your reply if it is indeed the reasons behind it (eg several engines running not knowing anything about each other). Still doesn't sound to me like a perfect solution but that might be the trade off to achieve the goal without complicating things …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks for your reply - much appreciated !&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Still keen to hear any other explanations - if there are any &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Adrian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:06:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242346#M195476</guid>
      <dc:creator>serid</dc:creator>
      <dc:date>2016-10-26T13:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Async service task is tried to be run several times</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242347#M195477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm ….&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just checked my main application class (which is Spring Boot) and I have:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@Bean(name="activitiAsyncJobExecutor")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;public DefaultAsyncJobExecutor activitiAsyncJobExecutor() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; DefaultAsyncJobExecutor bean = new DefaultAsyncJobExecutor();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setCorePoolSize(10);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setMaxPoolSize(100);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setKeepAliveTime(5000);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setQueueSize(100);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setMaxTimerJobsPerAcquisition(30);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setMaxAsyncJobsDuePerAcquisition(30);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setDefaultAsyncJobAcquireWaitTimeInMillis(1000);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setDefaultTimerJobAcquireWaitTimeInMillis(1000);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setTimerLockTimeInMillis(1000 * 60 * 60 * 12); // 12 hours&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setAsyncJobLockTimeInMillis(1000 * 60 * 60 * 12); // 12 hours&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return bean;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@Bean&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@DependsOn(value="applicationContextProvider")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;public SpringProcessEngineConfiguration activitiConfigurationBean() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; SpringProcessEngineConfiguration bean = new SpringProcessEngineConfiguration();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setJobExecutorActivate(false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setAsyncExecutorActivate(true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setAsyncExecutorEnabled(true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setDataSource(dataSource());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setTransactionManager(transactionManager());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setAsyncExecutor(activitiAsyncJobExecutor());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setDatabaseSchemaUpdate("true");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bean.setDeploymentResources(getActivitiResources());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return bean;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;which should have not been the 5 mins I am seeing ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:18:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242347#M195477</guid>
      <dc:creator>serid</dc:creator>
      <dc:date>2016-10-26T13:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Async service task is tried to be run several times</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242348#M195478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You were right - it is the current time ?! &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No idea how I was seeing other time in those tables …… &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for confusion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:22:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242348#M195478</guid>
      <dc:creator>serid</dc:creator>
      <dc:date>2016-10-26T13:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Async service task is tried to be run several times</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242349#M195479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok - I think I am doing something wrong … &lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://connect.hyland.com/i/smilies/16x16_smiley-indifferent.png" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have recompiled and rebuild the project and with those time settings (12 hours) it does work now …&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe I should slow down a bit &lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://connect.hyland.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:40:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/async-service-task-is-tried-to-be-run-several-times/m-p/242349#M195479</guid>
      <dc:creator>serid</dc:creator>
      <dc:date>2016-10-26T13:40:45Z</dc:date>
    </item>
  </channel>
</rss>

