Bug 808630 - "ERROR: duplicate key value violates unique constraint "pk_snapshots"", happens after a VM is renamed and imported in another export domain with the old name
"ERROR: duplicate key value violates unique constraint "pk_snapshots"", happe...
Status: CLOSED CURRENTRELEASE
Product: oVirt
Classification: Community
Component: ovirt-engine-core (Show other bugs)
unspecified
x86_64 Linux
unspecified Severity low
: ---
: 3.2
Assigned To: lpeer
storage
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-30 18:15 EDT by Andrey Falko
Modified: 2016-02-10 12:12 EST (History)
4 users (show)

See Also:
Fixed In Version: 3.2
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-25 16:48:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: Storage
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Andrey Falko 2012-03-30 18:15:57 EDT
Description of problem:
The logs return the following stacktrace:
2012-03-30 21:54:36,225 INFO  [org.ovirt.engine.core.bll.ImportVmCommand] (pool-5-thread-50) [21ec6c05] Running command: ImportVmCommand internal: false. Entities affected :  ID: 20ba7cc8-0164-49dd-90bf-7d72c6fed009 Type: Storage
2012-03-30 21:54:36,232 ERROR [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (pool-5-thread-50) [21ec6c05] Try to add duplicate values with same name. Type: UNASSIGNED. Value: vmname
2012-03-30 21:54:36,254 INFO  [org.ovirt.engine.core.utils.transaction.TransactionSupport] (pool-5-thread-50) [21ec6c05] transaction rolled back
2012-03-30 21:54:36,255 ERROR [org.ovirt.engine.core.bll.ImportVmCommand] (pool-5-thread-50) [21ec6c05] Command org.ovirt.engine.core.bll.ImportVmCommand throw exception: org.springframework.dao.DataIntegrityViolationException: CallableStatementCallback; SQL [{call insertsnapshot(?, ?, ?, ?, ?, ?, ?, ?)}]; ERROR: duplicate key value violates unique constraint "pk_snapshots"
  Where: SQL statement "INSERT INTO snapshots( snapshot_id, status, vm_id, snapshot_type, description, creation_date, app_list, vm_configuration) VALUES(  $1 ,  $2 ,  $3 ,  $4 ,  $5 ,  $6 ,  $7 ,  $8 )"
PL/pgSQL function "insertsnapshot" line 2 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pk_snapshots"
  Where: SQL statement "INSERT INTO snapshots( snapshot_id, status, vm_id, snapshot_type, description, creation_date, app_list, vm_configuration) VALUES(  $1 ,  $2 ,  $3 ,  $4 ,  $5 ,  $6 ,  $7 ,  $8 )"
PL/pgSQL function "insertsnapshot" line 2 at SQL statement
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:228) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:952) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:985) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:368) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:342) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:164) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeImpl(SimpleJdbcCallsHandler.java:112) [engine-dal.jar:]
        at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeModification(SimpleJdbcCallsHandler.java:39) [engine-dal.jar:]
        at org.ovirt.engine.core.dao.DefaultGenericDaoDbFacade.modify(DefaultGenericDaoDbFacade.java:81) [engine-dal.jar:]
        at org.ovirt.engine.core.dao.DefaultGenericDaoDbFacade.save(DefaultGenericDaoDbFacade.java:86) [engine-dal.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand.addVmImagesAndSnapshots(ImportVmCommand.java:536) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand.access$200(ImportVmCommand.java:73) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand$4.runInTransaction(ImportVmCommand.java:443) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand$4.runInTransaction(ImportVmCommand.java:439) [engine-bll.jar:]
        at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInNewTransaction(TransactionSupport.java:204) [engine-utils.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand.processImages(ImportVmCommand.java:439) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.ImportVmCommand.executeCommand(ImportVmCommand.java:419) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.ExecuteWithoutTransaction(CommandBase.java:746) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.executeActionInTransactionScope(CommandBase.java:838) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.runInTransaction(CommandBase.java:1144) [engine-bll.jar:]
        at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInSuppressed(TransactionSupport.java:168) [engine-utils.jar:]
        at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInScope(TransactionSupport.java:107) [engine-utils.jar:]
        at org.ovirt.engine.core.bll.CommandBase.Execute(CommandBase.java:853) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.CommandBase.ExecuteAction(CommandBase.java:260) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.MultipleActionsRunner.executeValidatedCommands(MultipleActionsRunner.java:174) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.MultipleActionsRunner.RunCommands(MultipleActionsRunner.java:155) [engine-bll.jar:]
        at org.ovirt.engine.core.bll.MultipleActionsRunner$1.run(MultipleActionsRunner.java:77) [engine-bll.jar:]
        at org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil$InternalWrapperRunnable.run(ThreadPoolUtil.java:64) [engine-utils.jar:]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [:1.6.0_22]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [:1.6.0_22]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166) [:1.6.0_22]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.6.0_22]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.6.0_22]
        at java.lang.Thread.run(Thread.java:679) [:1.6.0_22]
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pk_snapshots"
  Where: SQL statement "INSERT INTO snapshots( snapshot_id, status, vm_id, snapshot_type, description, creation_date, app_list, vm_configuration) VALUES(  $1 ,  $2 ,  $3 ,  $4 ,  $5 ,  $6 ,  $7 ,  $8 )"
PL/pgSQL function "insertsnapshot" line 2 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$5.doInCallableStatement(JdbcTemplate.java:987) [spring-jdbc-2.5.6.SEC02.jar:]
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:936) [spring-jdbc-2.5.6.SEC02.jar:]
        ... 32 more

2012-03-30 21:54:36,260 INFO  [org.ovirt.engine.core.bll.ImportVmCommand] (pool-5-thread-50) [21ec6c05] Command [id=30615dd8-5e08-452d-a25f-5062370ac2d9]: Compensating NEW_ENTITY_ID of org.ovirt.engine.core.common.businessentities.VmStatistics; snapshot: 47ff7785-3b87-430e-b056-3ef270020563.


Version-Release number of selected component (if applicable):
# rpm -qa | grep ovirt
ovirt-engine-restapi-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-backend-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-genericapi-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-jboss-deps-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-userportal-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-iso-uploader-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-image-uploader-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-log-collector-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-dbscripts-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-notification-service-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-tools-common-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-jbossas-1.2-2.fc16.x86_64
ovirt-engine-setup-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-webadmin-portal-3.1.0_0001-1.8.el6.x86_64
ovirt-engine-config-3.1.0_0001-1.8.el6.x86_64

How reproducible:
See steps below

Steps to Reproduce:
1. Have two datacenters
2. Attach an export domain to DC1, import VM after running virt-v2v
3. Detach export domain after VM is active
4. Attach the export domain to DC2
5. Rename VM
6. Import the VM in DC2
  
Actual results:
See exception above

Expected results:
Either better error messaging or renaming the VM allow me to re-import it in another datacenter

Additional info: The reason I did this operation is because there doesn't appear to be any way to copy templates/VMs between datacenters.
Comment 1 Allon Mureinik 2013-03-13 07:36:23 EDT
There have been several improvements to the import VM flow this this issue was reported.

Verified on Change-Id I54a3c720edf863dcbc520ef41194d3816f9a0048 - when reproducing this scenario, a popup will warn that the VM already exists and offer to either clone(=rename) it or abort the operation.

Note You need to log in before you can comment on or make changes to this bug.