From ff04eb8394d81750608a95bedf6ab8cd5244d5e8 Mon Sep 17 00:00:00 2001 From: Georgy Kibardin Date: Mon, 30 Jan 2017 11:47:50 +0300 Subject: [PATCH] Moving task cache update into task creation transaction Doing this we avoid inclusion of task cache update statement into the next transaction which may cause different problems such as deadlock. In this particular case we've got the following deadlock: 1. DeleteIBPImagesTask makes UPDATE tasks SET cache.... 2. Response handler in receiver makes SELECT clusters FOR UPDATE 3. The code following DeleteIBPImagesTask makes SELECT clusters FOR UPDATE 4. Response handler performs SELECTS tasks FOR UPDATE Change-Id: Ic8e5f2386364421b0667f920499e031f587f726e Closes-Bug: #1653083 --- nailgun/nailgun/task/task.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nailgun/nailgun/task/task.py b/nailgun/nailgun/task/task.py index f2d7db0d53..fec16a43dc 100644 --- a/nailgun/nailgun/task/task.py +++ b/nailgun/nailgun/task/task.py @@ -909,8 +909,9 @@ class DeleteIBPImagesTask(object): def execute(cls, cluster, image_data): task = Task(name=consts.TASK_NAMES.remove_images, cluster=cluster) db().add(task) + message = cls.message(task, image_data) db().commit() - rpc.cast('naily', cls.message(task, image_data)) + rpc.cast('naily', message) class StopDeploymentTask(object):