Violation of PRIMARY KEY constraint on startup after DB upgrade
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- After successfully upgrading your DB with the db-upgrade tool you might face a similar error to the following one on fresh startup:
2020-12-11 08:41:05.671 ERROR [main][JDBCExceptionReporter:234] Violation of PRIMARY KEY constraint 'PK__Resource__5BB6F3C1121C39C4'. Cannot insert duplicate key in object 'dbo.ResourceAction'. The duplicate key value is (4523).
2020-12-11 08:41:05.687 ERROR [main][PortletTracker:360] Portlet com_liferay_portal_workflow_metrics_web_internal_portlet_WorkflowMetricsPortlet from com.liferay.portal.workflow.metrics.web_1.0.25 [385] failed to initialize
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:446)
at com.liferay.portal.service.persistence.impl.ResourcePermissionPersistenceImpl.findByC_N_S_R(ResourcePermissionPersistenceImpl.java:4015)
at com.liferay.portal.service.persistence.impl.ResourcePermissionPersistenceImpl.findByC_N_S_R(ResourcePermissionPersistenceImpl.java:3873)
at com.liferay.portal.service.persistence.impl.ResourcePermissionPersistenceImpl.findByC_N_S_R(ResourcePermissionPersistenceImpl.java:3824)
...
Environment
- Liferay Portal 6.2
- Liferay DXP 7.x
Resolution
- You should review your properties set in portal-ext.properties and look for the following:
counter.increment=1
- Either delete this property if not needed or configure it properly so it does not cause any issues
Did this article resolve your issue ?