Sorting bits into bytes...

ERROR: duplicate key value violates unique constraint “pk_n_vm_config_info”

A customer ran into problems while upgrading vCenter from 6.x to 7.x and I was asked to assist the customer while they waited for VMware support. Luckily the customer had a working snapshot of vCenter 6.x… or so they taught. Because after going back to the snapshot, vCenter still failed to start.

I had a look at the vpxd.log file and saw this error:

VCDB vc ERROR:  duplicate key value violates unique constraint "pk_n_vm_config_info"
VCDB vc DETAIL:  Key (id)=(12345) already exists.

Note the Key (id) as we need to use this later on.

 

That looks like a duplicate entry in the Postgres Database. But how to fix this? I checked the VMware slack and had to combine several posts to come to the fix.

Here are my steps to success:

SSH to the vCenter and start “shell”

Stop the VPXD service:

service-control --stop vmware-vpxd

Connect to vPostgress:

/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres

Search for the internal VM ID using the Key (id) found in the vpxd.log:

select vm_id from vpx_vm_text where id=12345;

Run the following commands after replacing 0000 with the correct VM_ID as seen in the output of the previous step:

delete from  VPX_COMPUTE_RESOURCE_DAS_VM where VM_ID=0000;
delete from  VPX_COMPUTE_RESOURCE_DRS_VM where VM_ID=0000;
delete from  VPX_COMPUTE_RESOURCE_ORC_VM where VM_ID=0000;
delete from  VPX_VM_SGXINFO where VM_ID=0000;
delete from  VPX_GUEST_DISK where VM_ID=0000;
delete from  VPX_VM_VIRTUAL_DEVICE where ID=0000;
delete from  VPX_VM_DS_SPACE where VM_ID=0000;
delete from  VPX_NON_ORM_VM_CONFIG_INFO where ID=0000;
delete from  VPX_NORM_VM_FLE_FILE_INFO where VM_ID=0000;
delete from  VPX_VDEVICE_BACKING_REL where VM_ID=0000;
delete from  VPX_VIRTUAL_DISK_IOFILTERS where VM_ID=0000;
delete from  VPX_VM_STATIC_OVERHEAD_MAP where VM_ID=0000;
delete from  VPX_VM_TEXT where VM_ID=0000;
delete from  VPX_VM where ID=0000;
delete from  VPX_ENTITY where ID=0000;

Start the vpxd service:

service-control --start vmware-vpxd

 

Log on to the VAMI interface and reboot the vCenter. The duplicate entry found was of one of the vCLS VM’s. I guess during the upgrade DRS/HA span up a duplicate named vCLS VM.

 

I hope this helps!

Leave a Reply