VMware vCenter Server fails when adding a host or portgroup to a DVS
book
Article ID: 320206
calendar_today
Updated On:
Products
VMware vCenter Server
Issue/Introduction
Adding a host or port group to a DVS fails
When executing this SQL statement INSERT INTO VPX_DVPORT_MEMBERSHIP WITH (ROWLOCK) (DVS_ID, DVPORT_KEY, DVPORTGROUP_ID, HOST_ID) VALUES (?, ?, ?, ?), you see the error similar to:
ODBC error: (23000) - [Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of PRIMARY KEY constraint 'PK_VPX_DVPORT_MEMBERSHIP'. Cannot insert duplicate key in object 'VMW.VPX_DVPORT_MEMBERSHIP'. The duplicate key value is (6653, 0).
vCenter Server creates a dump file and fails
The same error is displayed in the vCenter Server Event Viewer and in the /var/log/vpxd.log file.
Environment
VMware vCenter Server 6.0.x
VMware vCenter Server 6.5.x
VMware vCenter Server 5.5.x
Cause
This issue occurs when a DVS configuration which was backed up and restored on vCenter Server, allocates a port ID that is not existent in memory but exists in the database.
Resolution
Modify the database using the SQL Management Studio.
Note: This procedure modifies the database. Ensure to take a backup of the database before proceeding.
To modify the database:
Take a backup of the database.
Stop the VMware VirtualCenter Server service.
Run this query in the SQL Management Studio:
Open the database:
Use vCenterDatabaseName
Where vCenterDatatbaseName is the name given to the vCenter database.
Confirm the DVS name, the id is taken from the Violation of PRIMARY KEY constraint error message:
Select * from VPX_DVS where id = 6653
Update the database:
Update VPX_DVS set port_counter=10768, upgrade_mode=1 where ID = 6653;
Note: The port_counter value of 10768 is heuristically chosen and can and may need to be larger, depending on the environment.