The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides
Upgrading VMware vCloud Usage Meter to version 2.3.2 fails with 'Foreign Key Constraint' errors (2041766)
- You cannot upgrade to vCloud Usage Meter 2.3.2 from earlier versions.
- After upgrading vCloud Usage Meter, data migration takes a very long time.
- You receive foreign key constraint errors in relation to the Collection table.
- You receive an error similar to the following:
java.lang.RuntimeException: Exception while executing statement : ERROR: insert or update on table "Collection" violates foreign key constraint "CollectionFK5" Detail: Key (vcServerId)=(1) is not present in table "VcServer". errorCode: 0, sqlState: 23503 insert into "Collection" ("id", "stop", "vcServerId", "ok", "start") values (nextval('"s_Collection_id"'),?,?,?,?)
The constraint CollectionFK5 is a constraint that presents between the Collection, Sample and VCServer table. This issue occurs when Usage Meter tries to migrate data belonging to a Virtual Center that is no longer present in the VcServer table.
Note: If you want to migrate to vCloud Usage Meter 3.0, you must upgrade from vCloud Usage Meter 2.3.2.
- To determine the cause of this conflict, run this select statement on the database:
select * from "Host";
select * from "Collection" where "VcID" IS NOT IN (X,Y,Z);
Note: X,Y and Z are the VcID values taken from the select statement on the Host table.
For information on connecting to the database, see the Additional Information section below.
- Remove the data from both the Sample and Collection table:
delete from "Sample" where "VcID" IS NOT IN (X,Y,Z);
delete from "Collection" where "VcID" IS NOT IN (X,Y,Z);
- Run the migrate option. Samples should be carried over.
Note: Apply Usage Meter 22.214.171.124 update9 to the vCloud Usage Meter before migrating data. If you do not have this update, please contact VMware support.
To connect to the vCloud Usage Meter database:
- su - postgres (change to the postgres user).
- psql -d usage_meter_db (this is the current database).
- psql -d um22 (this is the legacy database that is created during the migration process).
Note: This is the table you will run the statements on above. If you are unsure of the table names, run '\d' to list all of
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.