Make update_execution() atomic
@@ -48,6 +48,7 @@ from st2common.models.api.trigger import TriggerTypeAPI, TriggerAPI, TriggerInst
from st2common.models.db.execution import ActionExecutionDB
from st2common.runners import utils as runners_utils
from st2common.metrics.base import Timer
+from st2common.services import coordination
from six.moves import range
@@ -195,6 +196,7 @@ def update_execution(liveaction_db, publish=True, set_result_size=False):
"""
execution = ActionExecution.get(liveaction__id=str(liveaction_db.id))
+ with coordination.get_coordinator().get_lock(liveaction_db.id):
# Skip execution object update when action is already in completed state.
if execution.status in action_constants.LIVEACTION_COMPLETED_STATES:
LOG.debug(
