Bug 895563

Summary: [RHEVM] Failed import VM - duplicate key value violates unique constraint
Product: Red Hat Enterprise Virtualization Manager Reporter: vvyazmin <vvyazmin>
Component: ovirt-engineAssignee: Michal Skrivanek <michal.skrivanek>
Status: CLOSED DUPLICATE QA Contact: vvyazmin <vvyazmin>
Severity: urgent Docs Contact:
Priority: high    
Version: 3.2.0CC: acathrow, dyasny, hateya, iheim, lpeer, ofrenkel, Rhev-m-bugs, yeylon, ykaul
Target Milestone: ---Keywords: Regression, TestBlocker
Target Release: 3.2.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: virt
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-10 03:54:41 EST Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On:    
Bug Blocks: 862303, 885459    
Attachments:
Description Flags
## Logs rhevm none

Description vvyazmin@redhat.com 2013-01-15 09:35:13 EST
Created attachment 678796 [details]
## Logs rhevm

Description of problem:
Failed import VM - duplicate key value violates unique constraint

Version-Release number of selected component (if applicable):
RHEVM 3.2 - SF03 environment 

RHEVM: rhevm-3.2.0-4.el6ev.noarch 
VDSM: vdsm-4.10.2-3.0.el6ev.x86_64 
LIBVIRT: libvirt-0.10.2-13.el6.x86_64 
QEMU & KVM: qemu-kvm-rhev-0.12.1.2-2.348.el6.x86_64 
SANLOCK: sanlock-2.6-2.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create a new DC environment
2. Create a new VM
3. Export a VM & delete it from the setup (the vm only resides in export domain)
4. Import the VM

  
Actual results:
Failed import VM

Expected results:
Successfully import VM 
No exception should be found

Additional info:

/var/log/ovirt-engine/engine.log

2013-01-15 16:41:51,805 INFO  [org.ovirt.engine.core.bll.ImportVmCommand] (pool-3-thread-50) [61ed76f4] Running command: ImportVmCommand internal: false. Entities affected :  ID: 99b0eae7-b63c-4388-aece-cded09acbd61 Type: Storage
2013-01-15 16:41:51,811 INFO  [org.ovirt.engine.core.vdsbroker.irsbroker.GetVmsInfoVDSCommand] (ajp-/127.0.0.1:8702-10) FINISH, GetVmsInfoVDSCommand, log id: 21b53afd
2013-01-15 16:41:51,819 INFO  [org.ovirt.engine.core.utils.transaction.TransactionSupport] (pool-3-thread-50) [61ed76f4] transaction rolled back
2013-01-15 16:41:51,819 INFO  [org.ovirt.engine.core.bll.network.MacPoolManager] (pool-3-thread-50) [61ed76f4] MacPoolManager::freeMacs - entered
2013-01-15 16:41:51,819 ERROR [org.ovirt.engine.core.bll.ImportVmCommand] (pool-3-thread-50) [61ed76f4] Command org.ovirt.engine.core.bll.ImportVmCommand throw exception: org.springframework.dao.DuplicateKeyException: CallableStatementCa
llback; SQL [{call insertvmstatic(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]; ERROR: duplicate key value violates unique constraint "vm_ovf_generations_pkey"
  Where: SQL statement "INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id) VALUES ( $1 , (SELECT storage_pool_id FROM vds_groups vg WHERE vg.vds_group_id =  $2 ))"
PL/pgSQL function "insertvmstatic" line 4 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "vm_ovf_generations_pkey"
  Where: SQL statement "INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id) VALUES ( $1 , (SELECT storage_pool_id FROM vds_groups vg WHERE vg.vds_group_id =  $2 ))"
PL/pgSQL function "insertvmstatic" line 4 at SQL statement
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:241) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1030) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1064) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:388) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:351) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:181) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeImpl(SimpleJdbcCallsHandler.java:124) [engine-dal.jar:]
        at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeModification(SimpleJdbcCallsHandler.java:37) [engine-dal.jar:]
        at org.ovirt.engine.core.dao.VmStaticDAODbFacadeImpl.save(VmStaticDAODbFacadeImpl.java:34) [engine-dal.jar:]
        at org.ovirt.engine.core.dao.VmStaticDAODbFacadeImpl.save(VmStaticDAODbFacadeImpl.java:18) [engine-dal.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand.addVmStatic(ImportVmCommand.java:819) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand$3.runInTransaction(ImportVmCommand.java:511) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand$3.runInTransaction(ImportVmCommand.java:507) [engine-bll.jar:]
        at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInNewTransaction(TransactionSupport.java:202) [engine-utils.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand.addVmToDb(ImportVmCommand.java:507) [engine-bll.jar:]


        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09-icedtea]
        at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09-icedtea]
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "vm_ovf_generations_pkey"
  Where: SQL statement "INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id) VALUES ( $1 , (SELECT storage_pool_id FROM vds_groups vg WHERE vg.vds_group_id =  $2 ))"
PL/pgSQL function "insertvmstatic" line 4 at SQL statement
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:360)
        at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.execute(CachedPreparedStatement.java:297)
        at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:404)
        at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1066) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1014) [spring-jdbc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        ... 31 more


/var/log/vdsm/vdsm.log
Comment 2 Omer Frenkel 2013-02-10 03:54:41 EST

*** This bug has been marked as a duplicate of bug 890951 ***