YYYY-MM-DDTHH:MM:SS.054Z | DEBUG | ml9rbtxy-577498-auto-cdln-h5:70079657-6b-14 | cls-simple-activity-11 | SimpleActivityExecutor | submitting activity DeleteLibraryItemActivity (priority=NORMAL, phase=phaseBegin()YYYY-MM-DDTHH:MM:SS.069Z | INFO | ml9rbtxy-577498-auto-cdln-h5:70079657-6b-14-83 | cls-simple-activity-21 | DeleteLibraryItemActivity | Deleting library item 49d876fa-####-####-8fb7-599db6fdf26dYYYY-MM-DDTHH:MM:SS.069Z | DEBUG | ml9rbtxy-577498-auto-cdln-h5:70079657-6b-14-83 | cls-simple-activity-21 | TypeAdapterServiceImpl | Deleting type specific content of library item 49d876fa-####-####-8fb7-599db6fdf26dYYYY-MM-DDTHH:MM:SS.073Z | ERROR | ml9rbtxy-577498-auto-cdln-h5:70079657-6b-14-83 | cls-simple-activity-21 | SimpleActivityWorker | Exception will not be handled by activity DeleteLibraryItemActivity (handle=b6905707-####-####-98d4-2277a22450c0, entityId=49d876fa-####-####-8fb7-599db6fdf26d): query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2 at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:385) ~[spring-orm-5.3.36.jar:5.3.36] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:552) ~[spring-orm-5.3.36.jar:5.3.36] at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61) ~[spring-tx-5.3.36.jar:5.3.36] at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:243) ~[spring-tx-5.3.36.jar:5.3.36] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152) ~[spring-tx-5.3.36.jar:5.3.36] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.36.jar:5.3.36] at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145) ~[spring-data-jpa-2.7.17.jar:2.7.17] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.36.jar:5.3.36] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.36.jar:5.3.36]Duplicate entries for one or more content library items in vCenter's Database.
The issue can be identified and workaround by following the steps below
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgresSELECT * FROM cl_libraryitem_certificate_verification;Example: The screenshot below shows there are 3 pairs of the same item ID, which means there are 3 duplicate entries in the database.
To workaround this issue, need to delete the duplicate entries in the Content Library certificate database by following the steps below.
Note: Before applying the steps below, take a backup or a snapshot of the vCenter Server Appliance. If the vCenter is part of an Enhanced Linked Mode setup, take an offline snapshot of all the vCenters in Enhanced Linked Mode(ELM). VMware vCenter in Enhanced Linked Mode pre-changes snapshot (online or offline) best practice
service-control --stop vmware-content-libraryservice-control --stop vpxd/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgresDELETE FROM cl_libraryitem_certificate_verification cert_ver_old USING (SELECT MIN(ctid) as ctid, itemId FROM cl_libraryitem_certificate_verification GROUP BY itemId HAVING COUNT(*) > 1) cert_ver_new WHERE cert_ver_new.itemId = cert_ver_old.itemId AND cert_ver_new.ctid <> cert_ver_old.ctid;SELECT * FROM cl_libraryitem_certificate_verification;\qservice-control --start vmware-content-libraryservice-control --start vpxd