Merge "Fix race condition in refreshing "join" task state"
This commit is contained in:
@@ -409,6 +409,17 @@ def _refresh_task_state(task_ex_id):
|
||||
|
||||
wf_ctrl = wf_base.get_controller(wf_ex, wf_spec)
|
||||
|
||||
with db_api.named_lock(task_ex.id):
|
||||
# NOTE: we have to use this lock to prevent two (or more) such
|
||||
# methods from changing task state and starting its action or
|
||||
# workflow. Checking task state outside of this section is a
|
||||
# performance optimization because locking is pretty expensive.
|
||||
db_api.refresh(task_ex)
|
||||
|
||||
if (states.is_completed(task_ex.state)
|
||||
or task_ex.state == states.RUNNING):
|
||||
return
|
||||
|
||||
log_state = wf_ctrl.get_logical_task_state(task_ex)
|
||||
|
||||
state = log_state.state
|
||||
|
Reference in New Issue
Block a user