cancel
Showing results for 
Search instead for 
Did you mean: 

Update done by one task into DB is not getting reflected by second task when multiple tasks are triggered at once

tkarthik26
Champ in-the-making
Champ in-the-making
Hi,

I am claiming two different tasks in UI and when submitting it, it is entering a service task. Below are the sequence of actions taking place.

Task1:
1. Enters the service task
2. Fetches count of records matching some condition from DB
3. Performs some logic
4. Updates the count to DB at the end of current execution.

Task2 also follows the same steps immediately after the execution of Task1. However I am getting problem at #2 where Task2 has to now get the updated count done by Task1. Here it still fetches the original count which was there before the execution of Task1.

Do I have a way to stop the successive executions for a period of time so that the execution before gets flushed to DB.


Regards,
Karthik
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
Make the task async, and the transaction will be committed to the database, thus giving you the latest values in the next talk.

swamy2156
Champ on-the-rise
Champ on-the-rise
I too face the similar problem!!
1. I have a workflow as follows. START->TASK->SERVICETASK->END
2. I have a counter(incremented based on history variables of completed instances + current execution data).
3. From My UI, I selected 2 tasks and completed them simultaneously in multi-threaded environment. 2 tasks completed concurrently in 2 seperate threads and both executions sits in ServiceTask. TASK1 counter variable calculated correctly. But, TASK2 counter not considering TASK1 refreshed db data from database.
Is there a way to solve this concurrency problem?

thanks,
Swamy.


jbarrez
Star Contributor
Star Contributor
I'm not sure I'm following this? How does these two threads relate to one process instance? They both complete the task? (which should not be possible)