This issue is resolved in vCenter Server 6.0 Update 3 and vCenter Server 6.5 Update 1
Workaround:
To work around this issue, re-deploy the affected vSphere Distributed Switch. Alternatively, this issue can be fixed directly in the vCenter Server database.
To work around this issue directly in vCenter Server database:
Note: Ensure to stop vCenter Server and back up the database before proceeding with these steps.
- Identify the affected vSphere Distributed Switch by looking for this error message in the vCenter Server vpxd log file around the time of the failure. You must see an error that includes a string similar to:
Cannot insert duplicate key in object 'dbo.VPX_DVPORT_MEMBERSHIP'. The duplicate key value is (916,2)
Note: In this case, the important parts are the table prefix and the first number in parenthesis, as this tells us in this example that 916 is the affected switch's ID and dbo is the table prefix. Make a note of these values.
You can also use windows event viewer vpxd crash events to find the duplicate key error and DVS_ID Value.
- Log in to the SQL Management studio with an administrative user.
- Expand the databases on the left and double-click the vCenter Server database (default name VCDB).
- Run this SQL statement:
For Microsoft SQL:
UPDATE VPX_DVS SET PORT_COUNTER=((SELECT MAX( DVPORT_KEY+0 ) FROM VPX_DVPORT_MEMBERSHIP WHERE DVS_ID='DVS_ID' )+1) WHERE ID='DVS_ID';
For vPostgres SQL (vCenter Server Appliance):
UPDATE VPX_DVS SET PORT_COUNTER=((SELECT MAX(CAST(DVPORT_KEY AS INT)) FROM VPX_DVPORT_MEMBERSHIP WHERE DVS_ID='DVS_ID')+1) WHERE ID='DVS_ID';
Note: The DVS_ID needs to be changed to match the DVS_ID reported in the output from the error message.
- Repeat all steps for each affected distributed switch.