Bug 1077715

Summary: [engine] exporting thin-provision vm and its template in parallel fails with deadlock in db
Product: Red Hat Enterprise Virtualization Manager Reporter: Gadi Ickowicz <gickowic>
Component: ovirt-engineAssignee: Liron Aravot <laravot>
Status: CLOSED CURRENTRELEASE QA Contact: nlevinki <nlevinki>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.4.0CC: amureini, iheim, lpeer, nlevinki, rbalakri, Rhev-m-bugs, scohen, tnisan, yeylon
Target Milestone: ---   
Target Release: 3.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: ovirt-engine-3.5.0_beta Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-16 19:09:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1142923, 1156165    
Attachments:
Description Flags
engine logs none

Description Gadi Ickowicz 2014-03-18 13:23:28 UTC
Created attachment 875940 [details]
engine logs

Description of problem:
Attempting to export a thin-provision vm with multiple disks and its template in parallel fails during endAction of exportVm with the following exception, and the vm and disks remain locked:

2014-03-18 14:39:30,890 ERROR [org.ovirt.engine.core.bll.CommandAsyncTask] (org.ovirt.thread.pool-4-thread-15) [within thread]: endAction for action type ExportVm threw an exception.: javax.ejb.EJBTransactionRolle
dbackException: CallableStatementCallback; SQL [{call updateimagestatus(?, ?)}]; ERROR: deadlock detected
  Detail: Process 9079 waits for ShareLock on transaction 13418; blocked by process 8489.
Process 8489 waits for ShareLock on transaction 13417; blocked by process 9079.
  Hint: See server log for query details.
  Where: SQL statement "SELECT 1 FROM ONLY "public"."images" x WHERE "image_guid" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x"
SQL statement "UPDATE images SET imageStatus =  $1  WHERE image_guid =  $2 "
PL/pgSQL function "updateimagestatus" line 2 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: deadlock detected
  Detail: Process 9079 waits for ShareLock on transaction 13418; blocked by process 8489.
Process 8489 waits for ShareLock on transaction 13417; blocked by process 9079.
  Hint: See server log for query details.
  Where: SQL statement "SELECT 1 FROM ONLY "public"."images" x WHERE "image_guid" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x"
SQL statement "UPDATE images SET imageStatus =  $1  WHERE image_guid =  $2 "
PL/pgSQL function "updateimagestatus" line 2 at SQL statement
       at .......

Version-Release number of selected component (if applicable):
rhevm-3.4.0-0.3.master.el6ev.noarch

How reproducible:
?

Steps to Reproduce:
1. Create template from a vm with multiple disks
2. Create vm from template (thin-provision, *not* clone)
3. Start exporting template
4. start exporting vm (dialog will display warning about template not existing on target domain -> click OK to start the export)

Actual results:
Fails to export vm

Expected results:
Should succeed in exporting vm and template in parallel

Additional info:

Comment 1 Allon Mureinik 2014-03-18 22:56:17 UTC
Seems as though iterating over the disks in the endAction should be sorted somehow.

Comment 2 Gadi Ickowicz 2014-08-07 12:45:58 UTC
verified on ovirt-engine-3.5.0-0.0.master.20140804172041.git23b558e.el6.noarch

Comment 5 Allon Mureinik 2015-02-16 19:09:36 UTC
RHEV-M 3.5.0 has been released, closing this bug.