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

|
Updating the database during a vCloud Director 5.1 upgrade fails with error: Executing upgrade task: Upgrade to 2.0.208 (2036617)
Symptoms
- When upgrading to vCloud Director 5.1 the installation fails.
- You have shared VLANs for an external network (same VLAN ID is use for port-groups for different external networks).
- When the database attempts to update, you see error messages similar to the following:
Executing upgrade task: Upgrade to 2.0.208 ..../java.sql.BatchUpdateException: Violation of UNIQUE KEY constraint 'uq_tr_resource'. Cannot insert duplicate key in object 'dbo.resource_assignment'. at net.sourceforge.jtds.jdbc.JtdsStatement.executeBatch(JtdsStatement.java:944) at com.vmware.vcloud.upgrade.tasks.v2_0.ResourceAssignmentUpgradeTask.insertVLANs(ResourceAssignmentUpgradeTask.java:653) at com.vmware.vcloud.upgrade.tasks.v2_0.ResourceAssignmentUpgradeTask.processUniqueVlanInUseData(ResourceAssignmentUpgradeTask.java:596) at com.vmware.vcloud.upgrade.tasks.v2_0.ResourceAssignmentUpgradeTask.processVlanInUseData(ResourceAssignmentUpgradeTask.java:409) at com.vmware.vcloud.upgrade.tasks.v2_0.ResourceAssignmentUpgradeTask.call(ResourceAssignmentUpgradeTask.java:128) at com.vmware.vcloud.upgrade.tasks.v2_0.ResourceAssignmentUpgradeTask.call(ResourceAssignmentUpgradeTask.java:1) at com.vmware.vcloud.upgrade.SerialAggregateTask.call(SerialAggregateTask.java:43) at com.vmware.vcloud.upgrade.SerialAggregateTask.call(SerialAggregateTask.java:1) at com.vmware.vcloud.upgrade.AbstractDelegatingTask.doCall(AbstractDelegatingTask.java:124) at com.vmware.vcloud.upgrade.TransactionTask.doCall(TransactionTask.java:74) at com.vmware.vcloud.upgrade.AbstractDelegatingTask.call(AbstractDelegatingTask.java:103) at com.vmware.vcloud.upgrade.AbstractDelegatingTask.call(AbstractDelegatingTask.java:1) at com.vmware.vcloud.upgrade.AbstractDelegatingTask.doCall(AbstractDelegatingTask.java:124) at com.vmware.vcloud.upgrade.UpgradeTask.doCall(UpgradeTask.java:79) at com.vmware.vcloud.upgrade.AbstractDelegatingTask.call(AbstractDelegatingTask.java:103) at com.vmware.vcloud.upgrade.AbstractDelegatingTask.call(AbstractDelegatingTask.java:1) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) .[5] Unable to upgrade the database: java.lang.IllegalStateException: Exception encountered when upgrading Portgroup based network pool data
Resolution
Solution 1:
Remove the share for the VLANs that are using the same Port ID before performing an upgrade. Once the upgrade is complete you can once again share the VLANs using the option of Allow overlapping of external networks. To remove the share from the VLANs follow this procedure:
- Identify the external network names having the shared VLAN ids in vCenter Server, by checking the dvportgroups corresponding to these networks to see the VLAN id.
- To unshare the VLANs, assign new VLAN ids to these dvportgroups in vCenter Server. Make a note of the map of network names and the VLAN ids.
- In the vCloud Director User Interface, go to the Administration > General > Allow Overlapping External Networks and uncheck this field.
- In the vCloud Director database, run the following query for each external network where you assigned new VLAN ids:
UPDATE vlan_in_use SET vlan_id=<NewVLANID> WHERE id IN (SELECT id FROM vlan_in_use WHERE network_ref_id IN (SELECT id FROM logical_network WHERE name='<NameOfExternalNetwork' AND scope_type=1))
commit;
- After that, upgrade vCloud Director and you will not run into this issue.
Solution 2:
Launch an upgrade of vCloud Director 5.1, once the update of the database fails follow the directions below.
Note: Ensure that you take a backup of your database before completing modifications on the vCloud Director database. Depending on the type of database you are using for vCloud Director go to the appropriate section below.
Microsoft SQL
- Launch SQL Management Studio and connect to the vCloud Director database.
- Run the following queries:
SELECT * FROM [DB_NAME].dbo.resource_assignment
- USE [DB_NAME]
GO
ALTER INDEX [uq_tr_resource] ON [dbo].[resource_assignment] DISABLE
GO
- SELECT * FROM [DB_NAME].[dbo].[config]
- UPDATE [DB_NAME].[dbo].[config] SET value = '2.0.207.fix' WHERE name = 'database.schema.version'
- Run this command to re-launch the upgrade:
/opt/vmware/vcloud-director/bin/upgrade
The console output is as follows:
Do you wish to rebuild the database indexes? This may take several minutes. [Y/N] N
Would you like to start the vCloud Director service now? If you choose not to start it now, you can manually start it at any time using this command:
service vmware-vcd start
Start it now? [y/n] n
- Run these queries:
DELETE FROM resource_assignment WHERE id IN ( SELECT ra1.id FROM resource_assignment ra1 JOIN (SELECT min(id) as id, tracker_uri, resource_uri FROM resource_assignment GROUP BY tracker_uri,resource_uri HAVING COUNT(resource_uri)>1) temp ON ra1.tracker_uri = temp.tracker_uri AND ra1.resource_uri = temp.resource_uri AND ra1.id != temp.id)
- USE [DB_NAME]
GO
ALTER INDEX [uq_tr_resource] ON [dbo].[resource_assignment] REBUILD WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, SORT_IN_TEMPDB = OFF, ONLINE = OFF )
GO
- Run this command to start vCloud Director services.
service vmware-vcd start
- The upgrade should now be complete.
Oracle Database
- Connect to the vCloud Director database using SQL Plus
- Disable the constraint UQ_TR_RESOURCE on table resource_assignment:
ALTER TABLE RESOURCE_ASSIGNMENT disable constraint "UQ_TR_RESOURCE"
- Change the database.schema.version key in config table from 2.0.207.fix.transition to 2.0.207.fix:
UPDATE config SET value = '2.0.207.fix' WHERE name = 'database.schema.version'
- Run the following statement to create the constraint again:
ALTER TABLE org_prov_vdc ADD CONSTRAINT fk_network_pool FOREIGN KEY(net_pool_Id) REFERENCES network_pool (id); COMMIT
- Run the upgrade script again:
/opt/vmware/vcloud-director/bin/upgrade
- After upgrade, delete all the duplicate entries in resource_assignment pertaining to VLANs. (Delete such that no duplicate exist):
SELECT ra1.id, ra1.tracker_uri, ra1.resource_uri FROM resource_assignment ra1 JOIN (SELECT min(id) as id, tracker_uri, resource_uri FROM resource_assignment GROUP BY tracker_uri,resource_uri HAVING COUNT(resource_uri)>1) temp ON ra1.tracker_uri = temp.tracker_uri AND ra1.resource_uri = temp.resource_uri AND ra1.id != temp.id
DELETE FROM resource_assignment WHERE id IN ( SELECT ra1.id FROM resource_assignment ra1 JOIN (SELECT min(id) as id, tracker_uri, resource_uri FROM resource_assignment GROUP BY tracker_uri,resource_uri HAVING COUNT(resource_uri)>1) temp ON ra1.tracker_uri = temp.tracker_uri AND ra1.resource_uri = temp.resource_uri AND ra1.id != temp.id)
- Enable the constraint UQ_TR_RESOURCE on the table resource_assignment:
ALTER TABLE RESOURCE_ASSIGNMENT enable constraint "UQ_TR_RESOURCE"
- Restart the vCloud Director services:
service vmware-vcd start
- The upgrade should now be successful.
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):

