| 1 |
--- |
| 2 |
fixes: |
| 3 |
- | |
| 4 |
[`bug 1518012 <https://bugs.launchpad.net/mistral/+bug/1518012>`_] |
| 5 |
[`bug 1513456 <https://bugs.launchpad.net/mistral/+bug/1513456>`_] |
| 6 |
|
| 7 |
Fix concurrency issues by using READ_COMMITTED |
| 8 |
|
| 9 |
This release note describes bugs: |
| 10 |
* #1513456 - task stuck in RUNNING state when all action executions are finished regarding the problem and the fix. |
| 11 |
* #1518012- WF execution stays in RUNNING although task and action executions are in SUCCESS. |
| 12 |
|
| 13 |
This fix does not require any action from Mistral users and |
| 14 |
does not have any implications other than the bug fix. |
| 15 |
|
| 16 |
The state of a workflow execution was not updated even when all task |
| 17 |
executions were completed if some tasks finished at the same time as |
| 18 |
other tasks. |
| 19 |
|
| 20 |
Because we were using our connections with transaction isolation |
| 21 |
level = REPEATABLE_READ - Each process was using a snapshot of the DB |
| 22 |
created at the first read statement in that transaction. |
| 23 |
When a task finished and evaluated the state of all the other tasks |
| 24 |
it did not see the up-to-date state of those tasks - and so, because |
| 25 |
not all tasks were completed - the task did not change the workflow |
| 26 |
execution state. |
| 27 |
|
| 28 |
Similar behavior happened with multiple action executions under same |
| 29 |
task. On completion, each action execution checked the status of the |
| 30 |
other action executions and did not see the up-to-date state of these |
| 31 |
action execution - causing task execution to stay in RUNNING state. |
| 32 |
|
| 33 |
The solution is to change DB transaction isolation level from |
| 34 |
REPEATABLE_READ to READ_COMMITTED so process A can see changes committed |
| 35 |
in other transactions even if process A is in the middle of a transaction. |
| 36 |
|
| 37 |
A short explanation regarding the different isolation levels: |
| 38 |
|
| 39 |
- | |
| 40 |
|
| 41 |
REPEATABLE_READ - while in transaction, the first read operation to the |
| 42 |
DB creates a snapshot of the entire DB so you are guarantee that all the |
| 43 |
data in the DB will remain the same until the end of the transaction. |
| 44 |
|
| 45 |
REPEATABLE_READ example: |
| 46 |
* ConnectionA selects from tableA in a transaction. |
| 47 |
* ConnectionB deletes all rows from tableB in a transaction. |
| 48 |
* ConnectionB commits. |
| 49 |
* ConnectionA loops over the rows of tableA and fetches from tableB using the tableA_tableB_FK - ConnectionA will get rows from tableB. |
| 50 |
|
| 51 |
- | |
| 52 |
|
| 53 |
READ_COMMITTED - while in a transaction, every query to the DB will get |
| 54 |
the committed data. |
| 55 |
|
| 56 |
READ_COMMITTED example: |
| 57 |
* ConnectionA starts a transaction. |
| 58 |
* ConnectionB starts a transaction. |
| 59 |
* ConnectionA insert row to tableA and commits. |
| 60 |
* ConnectionB insert row to tableA. |
| 61 |
* ConnectionB selects tableA and gets two rows. |
| 62 |
* ConnectionB commits / rollback. |
| 63 |
|
| 64 |
Two good articles about isolation levels are: |
| 65 |
* `Differences between READ-COMMITTED and REPEATABLE-READ transaction isolation levels <https://www.percona.com/blog/2015/01/14/mysql-performance-implications-of-innodb-isolation-modes/>`_. |
| 66 |
* `MySQL performance implications of InnoDB isolation modes <https://www.percona.com/blog/2012/08/28/differences-between-read-committed-and-repeatable-read-transaction-isolation-levels/>`_. |