Issue
We are executing the upgrade from 7.0 to 2023.Q3 version and we are getting following warning:
2024-02-02 08:28:57.379 INFO [main][UpgradeProcess:119] Upgrading com.liferay.portal.upgrade.v7_4_x.UpgradeListType
2024-02-02 08:28:57.492 WARN [main][UpgradeListType:55] Unable to add list type
com.liferay.portal.kernel.log.LogSanitizerException: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (LIFERAY_OWN.SYS_C008532) violated__https://docs.oracle.com/error-help/db/ora-00001/ [Sanitized] at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:702) ~[ojdbc8.jar:23.3.0.23.09] at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:608) ~[ojdbc8.jar:23.3.0.23.09] [...stack fragment ommited...]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[hikaricp.jar:?]
at com.liferay.portal.upgrade.v7_4_x.UpgradeListType._addListType(UpgradeListType.java:51) ~[portal-impl.jar:?] at com.liferay.portal.upgrade.v7_4_x.UpgradeListType.doUpgrade(UpgradeListType.java:26) ~[portal-impl.jar:?] at com.liferay.portal.kernel.upgrade.UpgradeProcess.lambda$upgrade$0(UpgradeProcess.java:122) ~[portal-kernel.jar:?] [...stack fragment ommited...] at com.liferay.portal.tools.db.upgrade.client.DBUpgraderLauncher.main(DBUpgraderLauncher.java:45) [com.liferay.portal.tools.db.upgrade.client.jar:?] Caused by: com.liferay.portal.kernel.log.LogSanitizerException: Error : 1, Position : 0, SQL = insert into ListType (listTypeId, name, type_) values (:1 , :2 , :3 ), Original SQL = insert into ListType (listTypeId, name, type_) values (?, ?, ?), Error Message = ORA-00001: unique constraint (LIFERAY_OWN.SYS_C008532) violated_ [Sanitized] at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:710) ~[ojdbc8.jar:23.3.0.23.09] ... 35 more
It seems it cannot add records to the ListType table, a duplicated value error is produced in the primary key of the table (ListTypeId column).
Environment
- Upgrade from DXP 7.0 to DXP 7.4, 2023.Q3, 2023.Q4 or newer
Resolution
The upgrade cannot add entries to the ListType table because the "com.liferay.portal.kernel.model.ListType" counter in the Counter table has a lower value than existing ListType IDs
This mismatch creates a unique constraint violation (ORA-00001) as it tries to create a record using a ListTypeId value that already exits in the table.
To fix it, you have to follow these steps in DXP 7.0, before executing the upgrade process:
- Stop the server.
- Run this SQL to fix the counter value:
UPDATE COUNTER SET CURRENTID = ((SELECT MAX(LISTTYPEID) FROM LISTTYPE) + 1) WHERE NAME = 'com.liferay.portal.kernel.model.ListType'. - Start the DXP 7.0 server.
- Run this Groovy script to check the counter value:
println com.liferay.counter.kernel.service.CounterLocalServiceUtil.getCounter("com.liferay.portal.kernel.model.ListType"). - Verify the new counter value is greater than
SELECT max(LISTTYPEID) FROM LISTTYPE.
This ensures the counter generates IDs higher than existing entries, preventing collisions.
After completing these steps, proceed with executing the upgrade to the 2023.Q3 version.