Removing a copy of the vApp template fails with error 'query did not return a unique result: 2'
search cancel

Removing a copy of the vApp template fails with error 'query did not return a unique result: 2'

book

Article ID: 440537

calendar_today

Updated On:

Products

VMware Cloud Director VMware vSphere ESXi

Issue/Introduction

  • When a vApp template copy or move operation fails in VMware Cloud Director, attempting to delete the failed copy at the destination triggers an unintended deletion of the source template, resulting in data loss.
  • This issue can be verified when attempting to copy or move a template from one catalog to another. When the operation fails, deleting the failed copy from the destination catalog incorrectly removes the source vApp template along with its underlying VM in vCenter.
  • The /opt/vmware/vcloud-director/logs/vcloud-container-debug.log displays the following error:
    yyyy-mm-dd hh:mm:ss| ERROR | Backend-activity-pool-<REDACTED_SECRETS> | CopyContentsActivity | [Activity Execution] Uncaught Exception during Activity execution. Recent phase: com.vmware.vcloud.vdc.impl.CopyContentsActivity$CopyContentsPhase...
    java.util.concurrent.ExecutionException: org.hibernate.NonUniqueResultException: query did not return a unique result: 2
     at com.vmware.vcloud.activity.executors.ActivityRunner.run(ActivityRunner.java:136)
     ...
    Caused by: org.hibernate.NonUniqueResultException: query did not return a unique result: 2
     at org.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:844)
     at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
     ...
     at com.vmware.vcloud.fabric.storage.storedVm.impl.HibernateStoredVmDao.findByValRef(HibernateStoredVmDao.java:79)
     at com.vmware.vcloud.fabric.storage.placement.impl.LinkedClonePlacementUtil.findAllLinkedCloneSourceVms(LinkedClonePlacementUtil.java:90)
     at com.vmware.vcloud.fabric.storage.placement.impl.FPVirtualMachineStorageSelectorImpl.getPlacementParams(FPVirtualMachineStorageSelectorImpl.java:191)
     at com.vmware.vcloud.fabric.storage.placement.impl.FPVirtualMachineStorageSelectorImpl.selectStorageContainer(FPVirtualMachineStorageSelectorImpl.java:106)

Environment

VMware Cloud Director 10.6.x

Cause

The issue is specifically tied to environments where Fast Provisioning is enabled. When VCD attempts to locate source VMs for linked clones, duplicate entries cause the task to crash or behave incorrectly during cleanup, leading to the deletion of the wrong entity.

Resolution

This issue has been resolve in VMware Cloud Director 10.6.2 release.

Refer Release Notes

Additional Information

VMware Cloud Director Installation and Upgrade Guide.