VMware vCenter Server fails when adding a host or portgroup to a DVS
search cancel

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

Symptoms:
  • 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

To resolve this issue, 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:
  1. Take a backup of the database.
  2. Stop the VMware VirtualCenter Server service.
  3. Run this query in the SQL Management Studio:
     
    1. Open the database:

      Use vCenterDatabaseName

      Where vCenterDatatbaseName is the name given to the vCenter database.
       
    2. Confirm the DVS name, the id is taken from the Violation of PRIMARY KEY constraint error message:

      Select * from VPX_DVS where id = 6653
       
    3. 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.

4. Start the VMware VirtualCenter Server service.


Additional Information

For more detailed information and an a comprehensive workaround procedure, see Modifying vDS membership fails after upgrading from vCenter Server 5.1 to 5.5 (2092070).
Modifying vDS membership fails after upgrading from vCenter Server 5.1 to 5.5 or 5.5 to 6.0
ホストやポートグループを分散仮想スイッチ (DVS) に追加すると VMware vCenter Server が停止する