Upgrade vCenter Server from 7.0.x to 8.x fail due to database error psycopg2.IntegrityError: duplicate key value violates unique constraint "pk_vpx_entity_tag_xref"
search cancel

Upgrade vCenter Server from 7.0.x to 8.x fail due to database error psycopg2.IntegrityError: duplicate key value violates unique constraint "pk_vpx_entity_tag_xref"

book

Article ID: 344772

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • Upgrade fails during vpxd firstboot when it tries to migrate the tag association data from cis_kv_keyvalue table to vpx_entity_tag_xref table
vpxd_firstboot.py_xxxxx_stdout.log -
Migrating 1 tag associations from cis_kv_keyvalue table
Exception: Traceback (most recent call last):
File "/usr/lib/vmware-vpx/firstboot/vpxd_firstboot.py", line 1219, in Main migrate_tag_association_data() # FB - upgrade
File "/usr/lib/vmware-vpx/py/vpxd_svcs_utils.py", line 52, in migrate_tag_association_data
db_util._persist_associations(valid_rows)
File "/usr/lib/vmware-vpx/py/cis_kv_utils.py", line 147, in _persist_associations format(int(ta_field._monum), int(seq)))
psycopg2.IntegrityError: duplicate key value violates unique constraint "pk_vpx_entity_tag_xref"
DETAIL: Key (entity_id, tag_id)=(1, 2) already exists.
 



Environment

VMware vCenter Server 8.0.0

Cause

  • If there is a cross vCenter vMotion involving a VM with a tag attached, on the destination vCenter, the vm tag association gets stored in the cis_kv_keyvalue table
  • The same vm tag association information is stored in the vpx_entity_tag_xref table.
  • During vCenter upgrade from 7.0.x to 8.x, the migration of tag association data records workflow in vpxd firstboot tries to insert a record for the same association which violates the table constraints and fails

Resolution

NOTE:- Take backup and an Offline snapshot of the vCenter server before making changes

Copy the script to the vCenter Server, which will help filter the associations and safe copy the association data to vpx_entity_tag_xref and delete equivalent record from the cis_kv_keyvalue table. Thus there will be no further records to migrate from cis_kv_keyvalue table.

To access the Local tagging association data stored in VCDB (Postgres):

1. Initiate an SSH connection to the vCenter Server Appliance.
2. Enter the root user name and password when prompted.
3. Run this command to enable the Bash shell:

shell.set --enable True

4. Run this command to access the Bash shell: 

shell

5. Download and Copy the "migrate_tag_association_data.py" script to the issue reported vCenter Server Appliance 
6. Run the command :-

chmod +x migrate_tag_association_data.py

7. Run the command :- 

python3 migrate_tag_association_data.py


 

 

 

 

Attachments

migrate_tag_association_data get_app