ERROR: Update or Delete on Table “cluster_compute_resource_inv” Violates Foreign Key Constraint

Problem


When trying to detach a vCenter from vCloud Director 9.1 – for an upgrade to supported version we got the following error:

[ 8eeddedb-d2f5-4674-883f-1be4dd626d86 ] could not execute update queryERROR: update or delete on table “cluster_compute_resource_inv” violates foreign key constraint “fk_cc_dr_v_h_r_i2clu_com_re_in” on table “ccr_drs_vm_host_rule_inv”
Detail: Key (ccr_inv_id)=(9a93e8c1-d373-4911-9322-a896db94b5f7) is still referenced from table “ccr_drs_vm_host_rule_inv”.

Solution

It appeared that the issues was related to a stale DRS rule in vCenter. I removed the rules and then the vCenter detach was successful.