Details

    • Story Points:
      12
    • Databases:
      MySQL 5.6

      Description

      I've been testing future upgrade of Liferay from a liferay instance currently in 6.1.2 to 7.0 M7. Found a bug. Reporting it here:

      09:56:19,714 ERROR [localhost-startStop-1][MainServlet:216] com.liferay.portal.kernel.events.ActionException: com.liferay.portal.kernel.upgrade.UpgradeException: com.liferay.portal.kernel.upgrade.UpgradeException: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '186341' for key 'IX_C803899D'
      com.liferay.portal.kernel.events.ActionException: com.liferay.portal.kernel.upgrade.UpgradeException: com.liferay.portal.kernel.upgrade.UpgradeException: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '186341' for key 'IX_C803899D'
      	at com.liferay.portal.events.StartupAction.run(StartupAction.java:78)
      	at com.liferay.portal.servlet.MainServlet.processStartupEvents(MainServlet.java:1315)
      	at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:213)
      	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
      	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
      	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
      	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
      	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5266)
      	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5554)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
      	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
      	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
      	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)
      	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1912)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:744)
      Caused by: com.liferay.portal.kernel.upgrade.UpgradeException: com.liferay.portal.kernel.upgrade.UpgradeException: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '186341' for key 'IX_C803899D'
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:169)
      	at com.liferay.portal.kernel.upgrade.util.UpgradeProcessUtil._upgradeProcess(UpgradeProcessUtil.java:179)
      	at com.liferay.portal.kernel.upgrade.util.UpgradeProcessUtil.upgradeProcess(UpgradeProcessUtil.java:151)
      	at com.liferay.portal.kernel.upgrade.util.UpgradeProcessUtil.upgradeProcess(UpgradeProcessUtil.java:133)
      	at com.liferay.portal.events.StartupHelper.upgradeProcess(StartupHelper.java:164)
      	at com.liferay.portal.events.StartupHelperUtil.upgradeProcess(StartupHelperUtil.java:81)
      	at com.liferay.portal.tools.DBUpgrader.upgrade(DBUpgrader.java:142)
      	at com.liferay.portal.events.StartupAction.doRun(StartupAction.java:138)
      	at com.liferay.portal.events.StartupAction.run(StartupAction.java:72)
      	... 19 more
      Caused by: com.liferay.portal.kernel.upgrade.UpgradeException: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '186341' for key 'IX_C803899D'
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:169)
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:191)
      	at com.liferay.portal.upgrade.UpgradeProcess_7_0_0.doUpgrade(UpgradeProcess_7_0_0.java:68)
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:166)
      	... 27 more
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '186341' for key 'IX_C803899D'
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      	at com.mysql.jdbc.Util.getInstance(Util.java:386)
      	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
      	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
      	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
      	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
      	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
      	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794)
      	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
      	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
      	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
      	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
      	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:1449)
      	at com.liferay.portal.upgrade.v7_0_0.UpgradeDocumentLibrary.addDDMStructureLink(UpgradeDocumentLibrary.java:72)
      	at com.liferay.portal.upgrade.v7_0_0.UpgradeDocumentLibrary.updateFileEntryTypeDDMStructureLinks(UpgradeDocumentLibrary.java:294)
      	at com.liferay.portal.upgrade.v7_0_0.UpgradeDocumentLibrary.doUpgrade(UpgradeDocumentLibrary.java:97)
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:166)
      	... 30 more
      

      This error occurs on upgrade.v7_0_0.UpgradeDocumentLibrary. If we dig on this error I found on 7.0 M7 source that the error happens in this function:

      	protected void updateFileEntryTypeDDMStructureLinks() throws Exception {
      		Connection con = null;
      		PreparedStatement ps = null;
      		ResultSet rs = null;
      
      		try {
      			con = DataAccess.getUpgradeOptimizedConnection();
      
      			ps = con.prepareStatement(
      				"select * from DLFileEntryTypes_DDMStructures");
      
      			rs = ps.executeQuery();
      
      			long classNameId = PortalUtil.getClassNameId(DLFileEntryType.class);
      
      			while (rs.next()) {
      				long structureId = rs.getLong("structureId");
      				long fileEntryTypeId = rs.getLong("fileEntryTypeId");
      
      				addDDMStructureLink(
      					increment(), classNameId, fileEntryTypeId, structureId);
      			}
      		}
      		finally {
      			DataAccess.cleanUp(con, ps, rs);
      		}
      
      		runSQL("drop table DLFileEntryTypes_DDMStructures");
      	}
      

      What this is doing is to migrate from one table DDMStructures to a new one DDMStructureLinks. The problem comes on the constraint that makes the fileEntryTypeId field unique on the new table.

      Analyzing the data on the DB the key 186341 corresponds to DLFileEntryType MarketingBanner (added by liferay on previous version as sample). This fileEntryType is associated with 2 structureIds (other 2 entry types have the same problem). This means that the corresponding migration fails trying to do 2 inserts.

      Actually, one file entry type can be associated to more than one structure (you can do it on the interface in 6.1.2). Although I did not add anything.

      The problem appears due to the entry type itself having fields (which is internally represented as a structure) and being linked to a structure.

      This problem can be easily reproduced since all this data comes from the original liferay installation and not from use.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              yvonne.han Yvonne Han
              Reporter:
              i.paz Iñaki Paz
              Participants of an Issue:
              Recent user:
              Brian Wulbern
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                5 years, 20 weeks, 6 days ago

                  Packages

                  Version Package
                  7.0.0 Alpha 2