[UTC:2018-09-07 11:05:49,831 Local:2018-09-07 11:05:49,831] vcac: [component="cafe:catalog" priority="ERROR" thread="tomcat-http--49" tenant="tenant-name" context="mwMhych9" parent="" token="mwMhych9"] com.vmware.vcac.platform.service.rest.resolver.ApplicationExceptionHandler.handleUnexpectedException:874 - result returns more than one elements; nested exception is javax.persistence.NonUniqueResultException: result returns more than one elements
org.springframework.dao.IncorrectResultSizeDataAccessException: result returns more than one elements; nested exception is javax.persistence.NonUniqueResultException: result returns more than one elements
# select * from public.cat_tenant;
id | lastsync | name
---------------+-------------------------+---------------
TENANT | 2017-11-22 17:00:04.934 | TENANT
tenant | 2018-09-06 19:05:14.954 | TENANT
vsphere.local | 2018-09-06 20:27:57.591 | vsphere.local
(3 rows)
To work around the issue, remove the dependency and delete the old tenant.
Caution: The following steps involve deletion of data. Ensure you have taken valid snapshots of the appliance(s).
# select * from public.cat_tenant;
id | lastsync | name
---------------+-------------------------+---------------
TENANT | 2017-11-22 17:00:04.934 | TENANT
tenant | 2018-09-06 19:05:14.954 | TENANT
vsphere.local | 2018-09-06 20:27:57.591 | vsphere.local
(3 rows)
Attempt to delete the tenant:
BEGIN;
# delete from cat_tenant where id='TENANT';
COMMIT;
Else, ROLLBACK;
ERROR: update or delete on table "cat_tenant" violates foreign key constraint "cat_icon__tenant_id__cat_tenant__id__fkey" on table "cat_icon"
DETAIL: Key (id)=(TENANT) is still referenced from table "cat_icon".
select * from public.cat_icon;
id | contenttype | filename | image | subtenant_id | tenant_id
------------------------------------------------------------+-------------+------------------------------------------------------------+-------+--------------+----------
cafe_default_icon_genericCatalogItem | image/png | genericCatalogItem.png | 26344 | |
cafe_default_icon_genericService | image/png | genericService.png | 26345 | |
cafe_default_icon_genericResourceOperation | image/png | genericResourceOperation.png | 26346 | |
cafe_default_icon_genericAllServices | image/png | genericAllServices.png | 26347 | |
software_catalog_item_icon | image/png | software_catalog_item_icon | 26348 | |
ServiceIcon-1495091052664 | image/png | Linux.png | 26629 | | tenant
ServiceIcon-1495091070014 | image/png | Windows (1).png | 26630 | | tenant
ServiceIcon-1495091098833 | image/png | VCO.png | 26631 | | TENANT
BEGIN;
UPDATE cat_icon SET tenant_id = 'tenant' WHERE tenant_id = 'TENANT';
delete from cat_tenant where id='TENANT';
COMMIT;
Else, ROLLBACK;