For me this happened during tests with the vCenter Appliance 6.5 after I tried to migrate a VMkernel port for management traffic from a vSwitch to a vDS on ESXi 6U2. It was the same VMkernel that was handling the connection with vCenter (and that host was also running the vCenter VM), and that also resulted in a few other issues: looking directly at the host (using the vSphere C# client) via a secondary VMkernel, nothing seemed to have changed, but still ESX wasn't responding to API calls on that port and forced me to reboot the host after trying to get that VMkernel back up. Anyways, after a few modifications on the host I ran into the duplicate key issue (see below for extracts from the log).
Wasn't able to remove the host from the cluster in vCenter Web Client, so I restarted vCenter Server and tried with the HTML5 ui, which, to my surprise, worked. Still, I couldn't add the host again (a network timeout according to the GUI after entering credentials; ping from the vCenter appliance worked, connecting to that VMkernel port from the C# client worked), so I deleted the cluster and also tried deleting the data center (no luck with that). Another reboot of the host solved this and I was able to add it to vCenter, and no more issues so far.
Summary:
Hope that helps anyone who doesn't want to dig into the database. I was ready to do it on the server directly, for which I found the instructions here quite helpful to issue SQL commands directly inside the vCenter Appliance VM: Reviewing and Managing Local and Global Permissions in vCenter Server 6.0 (2123931) | VMware KB
] Bind parameters:
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [0]datatype: 1, size: 4, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = 30
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [1]datatype: 1, size: 4, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = 1000
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [2]datatype: 11, size: 26, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = "LSI Logic SAS"
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [3]datatype: 11, size: 34, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = "SCSI controller 0"
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [4]datatype: 1, size: 4, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = 100
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [5]datatype: 1, size: 4, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = 3
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [6]datatype: 11, size: 84, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = "vim.vm.device.VirtualLsiLogicSASController"
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] [7]datatype: 11, size: 1188, arraySize: 0
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [VdbStatement ] value = "<obj xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml ns="urn:vim25" versionId="6.5" xsi:type="VirtualLsiLogicSASController"><key>1000</key><device..."
2017-01-08T02:52:01.334Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] [Vdb::IsRecov erableErrorCode] Unable to recover from 23505:7
[...]
SQLError was thrown: "ODBC error: (23505) - ERROR: duplicate key value violates unique constraint "pk_vpx_vm_virtual _device";
--> Error while executing the query" is returned when executing SQL statement "INSERT INTO VPX_VM_VIRTUAL_DEVICE (ID, DEVICE_KEY, DEVICE_INFO_SUMMARY, DEVICE_INFO_LABEL, DEVICE_CONTROLLER_KEY, DEVICE_UNIT_NUMBER, DEVICE_TYPE, DEVICE_TEX T) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
2017-01-08T02:52:01.343Z error vpxd[7F101ADDB700] [Originator@6876 sub=vpxCommon opID=QS-host-15-5916c471] [Vpxd_Handl eVmRootError] Received unrecoverable VmRootError. Generating minidump ...
2017-01-08T02:52:01.343Z error vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471] An unrecovera ble problem has occurred, stopping the VMware VirtualCenter service. Error: Error[VdbODBCError] (-1) "ODBC error: (235 05) - ERROR: duplicate key value violates unique constraint "pk_vpx_vm_virtual_device";
--> Error while executing the query" is returned when executing SQL statement "INSERT INTO VPX_VM_VIRTUAL_DEVICE (ID, DEVICE_KEY, DEVICE_INFO_SUMMARY, DEVICE_INFO_LABEL, DEVICE_CONTROLLER_KEY, DEVICE_UNIT_NUMBER, DEVICE_TYPE, DEVICE_TEX T) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
2017-01-08T02:52:01.348Z panic vpxd[7F101ADDB700] [Originator@6876 sub=Default opID=QS-host-15-5916c471]
-->
--> Panic: Unrecoverable VmRootError. Panic!