Knowledge Base
The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides

|
Upgrading to vCloud Director 5.1 fails with the error: java.sql.SQLException: Violation of UNIQUE KEY constraint 'uq_os_name_version_update'. Cannot insert duplicate key in object 'dbo.os'. (2036620)
Symptoms
- Cannot upgrade to vCloud Director 5.1
- Upgrading th vCloud Director 5.1 fails while updating the database
- You see the error:
Unable to upgrade the database: java.sql.SQLException: Violation of UNIQUE KEY constraint 'uq_os_name_version_update'. Cannot insert duplicate key in object 'dbo.os'.
- In the upgrade log file, you see entries similar to:
2012-09-13 15:57:19,171 | DEBUG | pool-1-thread-1 | SerialAggregateTask | ToledoToT2_Data.sql: Beginning execution of task ToledoToT2_Data.sql[98-99] | 2012-09-13 15:57:19,172 | DEBUG | pool-1-thread-1 | RawSQLTask | Executing sql 'INSERT INTO os (os_id, os_type, name, version, update_level, is_supported) VALUES (11, 'vmnix-x86', 'VMware ESXi', '5.1.0', 0, 1);' | 2012-09-13 15:57:19,200 | WARN | pool-1-thread-1 | SerialAggregateTask | ToledoToT2_Data.sql: Task failed due to uncaught exception | java.sql.SQLException: Violation of UNIQUE KEY constraint 'uq_os_name_version_update'. Cannot insert duplicate key in object 'dbo.os'.
Resolution
This issue may also occur if an installation occurred where an ESX/ESXi upgrade was performed before upgrading vCloud Director 5.1 with an unsupported operating system. As a result, vCloud Director detects the unsupported version and adds an entry to the database noting that the current version of vCloud Director is unsupported.
To work around this issue:
Note: This workaround requires you to modify your vCloud Director 5.1 database. Ensure you take a backup of your database before proceeding.
Note: This workaround requires you to modify your vCloud Director 5.1 database. Ensure you take a backup of your database before proceeding.
- Restore the database from a backup. If you are unsure of how to properly restore a vCloud Director database, contact VMware Support before proceeding.
- Launch SQL Management Studio or SQL Plus and connect to the vCloud Director database.
- In the vCloud Database operating system table, modify the record for the ESXi 5.1 operating system, so that it refers to something else (for example, set the update_level column to 999) by running this query:
UPDATE os SET update_level=999 WHERE name='VMware ESXi' AND version='5.1.0'
- Run this command to re-launch the upgrade:
/opt/vmware/vcloud-director/bin/upgrade
- After the upgrade completes, use this query to update all values that point to the record from the above step to point to the record added as part of upgrade:
UPDATE managed_server SET os_id=(SELECT os_id FROM os WHERE name='VMware ESXi' AND version='5.1.0' AND update_level=999) WHERE os_id=(SELECT os_id FROM os WHERE name='VMware ESXi' AND version='5.1.0' AND update_level=0)
- Run this query to remove the record from Step 3:
DELETE FROM os WHERE name='VMware ESXi' AND version='5.1.0' AND update_level=999
You should now be able to perform the upgrade.
See Also
Request a Product Feature
To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.
Actions
KB:
- Updated:
- Categories:
- Languages:
- Product Family:
- Product(s):
- Product Version(s):

