Liferay 6.1 GA1 Image Gallery upgrade fails - unique constraint violation

Description

See related forum thread:
http://www.liferay.com/community/forums/-/message_boards/message/12218337

To reproduce:
1. In 6.0.x, create 2 image gallery entities that have the same groupId, folderId, and name values in the igimage table.
2. Perform migration to 6.1

Upgrade will fail on the UpgradeImageGallery step:
19:49:25,440 INFO [UpgradeProcess:205] Upgrading com.liferay.portal.upgrade.v6_1_0.UpgradeImageGallery
19:49:25,597 ERROR [MainServlet:198] com.liferay.portal.kernel.events.ActionException: com.liferay.portal.kernel.upgrade.UpgradeException: com.liferay.portal.kernel.upgrade.UpgradeException: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry '10546-0-bengals' for key 'IX_ED5CA615'
com.liferay.portal.kernel.events.ActionException: com.liferay.portal.kernel.upgrade.UpgradeException: com.liferay.portal.kernel.upgrade.UpgradeException: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry '10546-0-bengals' for key 'IX_ED5CA615'

Note that the igimage table uses a non-unique index for these 3 columns: KEY `IX_AAE8DF83` (`groupId`,`folderId`,`name`)
Note that the dlentryfile table uses a unique index for the corresponding migration columns: UNIQUE KEY `IX_ED5CA615` (`groupId`,`folderId`,`title`)
The UpgradeImageGallery step needs some extra logic to handle this situation.

Attachments

1

Activity

Show:

Michael SaechangFebruary 3, 2012 at 11:53 AM

Closing as per Mika's comment.

MikaMFebruary 2, 2012 at 12:22 PM

This issue has been resolved already in

Michael SaechangJanuary 30, 2012 at 11:28 AM

Updated ticket as per Drew's comment. Thank you for verifying.

Drew BlessingJanuary 29, 2012 at 7:43 PM

Trey,

Thanks for the additional information. I have looked at the database a little closer. The indexes are indeed as you have suggested - Unique for the DLFileEntry table and non-unique for IGImage table. I am thinking that perhaps the upgrade scripts should check for, and correct, any non-unique keys and then migrate them successfully to the new table.

Trey HowardJanuary 29, 2012 at 7:27 PM

I found this problem in our staging environment.
We were running 6.0.5 since our initial install ~Oct 2010.
I couldn't tell you when/how the duplicate records were created--I just found the duplicate data when inspecting the database.
It's probably worth mentioning that the image gallery did not display any images in this environment.
If the system was corrupt, then perhaps this is just a tangential effect of a more serious unknown bug that allows the system to be corrupted.

From a data integrity perspective, if the code is going to enforce the groupId-folderId-name as unique then shouldn't the table use a unique index?
IMO, that's at the root of this problem: image gallery data being migrated from a non-unique index to a unique index.

-Trey

Duplicate
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Epic/Theme

Fix Priority

4

Affects versions

Priority

Zendesk Support

Created January 24, 2012 at 10:03 AM
Updated June 24, 2023 at 3:53 PM
Resolved February 2, 2012 at 12:22 PM