Error "update or delete on table "virtual_center" violates foreign key constraint "fk_vm_virtualcenter" on table "vm"" while unregistering the vCenter from VCD
search cancel

Error "update or delete on table "virtual_center" violates foreign key constraint "fk_vm_virtualcenter" on table "vm"" while unregistering the vCenter from VCD

book

Article ID: 378732

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • While attempting to unregister the vCenter in VMware Cloud Director, it fails with an error: update or delete on table "virtual_center" violates foreign key constraint "fk_vm_virtualcenter" on table "vm"

  • From "/opt/vmware/vcloud-director/logs/vcloud-container-debug.log", you will notice following exception while unregistering the vCenter:

2024-09-25 10:57:05,305 | ERROR    | task-service-activity-pool-699 | JDBCExceptionReporter  | ERROR: update or delete on table "virtual_center" violates foreign key constraint "fk_vm_virtualcenter" on table "vm"

Detail: Key (id)=(8xxxxxxx2-7xxa-42xx-xx20-5xxxxxxxx5) is still referenced from table "vm". | requestId=7xxxxxx5-cxxb-xx25-93xx-7xxxxxxxxxx1,request=POST https://VCD_URL/api/admin/extension/vimserver/8xxxxxxx2-7xxa-42xx-xx20-5xxxxxxxx5/action/unregister,requesttime=1727233024163,remoteaddress=xx.xx.xx.xx:33728,useragent=mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (...,accept=application/*+json;version 38.0.0-alpha vcd=6xxxxxxe-5xx9-xxa8-b4xx-6xxxxxxxxxc,task=axxxxxx2-xxcc-4cxx-9xx9-cxxxxxxxxxf activity=(com.vmware.vcloud.backendbase.management.system.TaskActivity,urn:uuid:axxxxxx2-xxcc-4cxx-9xx9-cxxxxxxxxxf)

Environment

VMware Cloud Director 10.x

Cause

This issue occurs when there are still vm objects in the database which are referencing to this vCenter that most likely have not been deleted. 

Resolution

    1. This requires modification of the Cloud Director database
    2. Take a backup of Cloud Director before proceeding. For Appliance based Cloud Director Cells see the VMware Cloud Director documentation, Backup and Restore of VMware Cloud Director Appliance
    3. For assistance, contact Broadcom Support and note this Article ID (378732) in the problem description. For more information, see Creating and managing Broadcom support cases