Bug 892645

Summary: Import VM fails when trying to import VM to the same datacenter (After delete the original VM)
Product: Red Hat Enterprise Virtualization Manager Reporter: Meni Yakove <myakove>
Component: ovirt-engineAssignee: Liron Aravot <laravot>
Status: CLOSED DUPLICATE QA Contact: Meni Yakove <myakove>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.2.0CC: abaron, amureini, dyasny, hateya, iheim, lpeer, Rhev-m-bugs, yeylon, ykaul
Target Milestone: ---Keywords: Regression
Target Release: 3.2.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: storage
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-14 10:28:35 EST Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 872100    
Attachments:
Description Flags
engine.log none

Description Meni Yakove 2013-01-07 08:54:56 EST
Created attachment 674061 [details]
engine.log

Description of problem:
Import VM fails when trying to import VM to the same datacenter (After delete the original VM), Duplicate vm_guid on table vm_ovf_generations. It seems that delete VM not clearing the table.


2013-01-08 01:26:02,058 ERROR [org.ovirt.engine.core.bll.ImportVmCommand] (pool-3-thread-50) [9d0a098] Command org.ovirt.engine.core.bll.ImportVmCommand throw exception: org.springframework.dao.DuplicateKeyException
: CallableStatementCallback; SQL [{call insertvmstatic(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]; ERROR: duplicate key value violates u
nique 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 org.ovirt.engine.core.bll.ImportVmCommand.executeCommand(ImportVmCommand.java:489) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.executeWithoutTransaction(CommandBase.java:997) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.executeActionInTransactionScope(CommandBase.java:1082) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.runInTransaction(CommandBase.java:1463) [engine-bll.jar:]
        at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInSuppressed(TransactionSupport.java:166) [engine-utils.jar:]
        at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInScope(TransactionSupport.java:108) [engine-utils.jar:]
        at org.ovirt.engine.core.bll.CommandBase.execute(CommandBase.java:1100) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.executeAction(CommandBase.java:302) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.MultipleActionsRunner.executeValidatedCommands(MultipleActionsRunner.java:200) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.MultipleActionsRunner.RunCommands(MultipleActionsRunner.java:180) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.MultipleActionsRunner$1.run(MultipleActionsRunner.java:101) [engine-bll.jar:]
        at org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil$InternalWrapperRunnable.run(ThreadPoolUtil.java:68) [engine-utils.jar:]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_09-icedtea]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_09-icedtea]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_09-icedtea]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09-icedtea]
        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]

Version-Release number of selected component (if applicable):
rhevm-3.2.0-4.el6ev.noarch



Steps to Reproduce:
1. Create VM1 
2. Export VM1
3. Delete VM1 
4. Import VM1
  
Actual results:
Import VM1 fails.

Expected results:
Import VM1 should succeed.


More info:

Before delete the original VM:
engine=# SELECT * from vm_ovf_generations ;
               vm_guid                |           storage_pool_id            | ovf_generation 
--------------------------------------+--------------------------------------+----------------
 afbc08c6-4034-454a-ba12-8639a481c2bf | e1e50b86-658c-4571-a75a-7d899dd27028 |              0


After delete the original VM:
engine=# SELECT * from vm_ovf_generations ;
               vm_guid                |           storage_pool_id            | ovf_generation 
--------------------------------------+--------------------------------------+----------------
 afbc08c6-4034-454a-ba12-8639a481c2bf | e1e50b86-658c-4571-a75a-7d899dd27028 |              0
Comment 2 Ayal Baron 2013-01-14 09:55:08 EST
Liron, this looks like a duplicate to me?
Comment 3 Liron Aravot 2013-01-14 10:28:35 EST
Ayal, indeed- duplicate of
https://bugzilla.redhat.com/show_bug.cgi?id=890951

http://gerrit.ovirt.org/#/c/10684/

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