Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-70401

UpgradeKaleoProcessTemplateLink.updateKaleoProcess can cause a SQLException, making the upgrade fail

    Details

    • Branch Version/s:
      7.0.x
    • Backported to Branch:
      Committed
    • Story Points:
      1
    • Fix Priority:
      4

      Description

      Description
      UpgradeKaleoProcessTemplateLink.updateKaleoProcess can cause a unique constraint or index violation: IX_6F3B3E9C error, which causes the upgrade of the module to fail. This happens because we falsely assume that there is not already an entry in the DDMTemplateLinkLocalService table for a given KaleoProcess with a DDMTemplate.

      Steps to Reproduce

      1. Start a clean SP1 bundle downloaded from files.liferay connected to a fresh database.
      2. Create a new Form through Kaleo Forms Admin.
      3. Shut down Liferay.
      4. Compile ee-7.0.x and point your ee-7.0.x bundle to your database from step 1.
      5. Start up your ee-7.0.x bundle.

      Expected results: The module upgrades for Kaleo complete with no errors
      Actual results: The following stack trace appears in the logs:

      java.lang.RuntimeException: com.liferay.portal.kernel.upgrade.UpgradeException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
      	at com.liferay.portal.upgrade.internal.release.ReleaseManagerOSGiCommands$UpgradeInfosRunnable.run(ReleaseManagerOSGiCommands.java:490)
      	at com.liferay.portal.output.stream.container.OutputStreamContainerFactoryTracker.runWithSwappedLog(OutputStreamContainerFactoryTracker.java:100)
      	at com.liferay.portal.upgrade.internal.release.ReleaseManagerOSGiCommands.executeUpgradeInfos(ReleaseManagerOSGiCommands.java:294)
      	at com.liferay.portal.upgrade.internal.release.ReleaseManagerOSGiCommands.doExecute(ReleaseManagerOSGiCommands.java:250)
      	at com.liferay.portal.upgrade.internal.release.ReleaseManagerOSGiCommands$UpgradeInfoServiceTrackerMapListener.keyEmitted(ReleaseManagerOSGiCommands.java:440)
      	at com.liferay.portal.upgrade.internal.release.ReleaseManagerOSGiCommands$UpgradeInfoServiceTrackerMapListener.keyEmitted(ReleaseManagerOSGiCommands.java:430)
      	at com.liferay.osgi.service.tracker.collections.internal.map.ServiceTrackerMapImpl$DefaultEmitter.emit(ServiceTrackerMapImpl.java:222)
      	at com.liferay.osgi.service.tracker.collections.map.PropertyServiceReferenceMapper.map(PropertyServiceReferenceMapper.java:43)
      	at com.liferay.osgi.service.tracker.collections.internal.map.ServiceTrackerMapImpl$ServiceReferenceServiceTrackerCustomizer.addingService(ServiceTrackerMapImpl.java:261)
      	at com.liferay.osgi.service.tracker.collections.internal.map.ServiceTrackerMapImpl$ServiceReferenceServiceTrackerCustomizer.addingService(ServiceTrackerMapImpl.java:248)
      	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
      	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
      	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
      	at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
      	at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
      	at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
      	at com.liferay.osgi.service.tracker.collections.internal.map.ServiceTrackerMapImpl.open(ServiceTrackerMapImpl.java:94)
      	at com.liferay.osgi.service.tracker.collections.map.ServiceTrackerMapFactory.openMultiValueMap(ServiceTrackerMapFactory.java:244)
      	at com.liferay.portal.upgrade.internal.release.ReleaseManagerOSGiCommands.activate(ReleaseManagerOSGiCommands.java:213)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224)
      	at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39)
      	at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617)
      	at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501)
      	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:302)
      	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:294)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:297)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:108)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:748)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:1012)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:968)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167)
      	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127)
      	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:917)
      	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:886)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:873)
      	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:132)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:940)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:740)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:1012)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:968)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167)
      	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127)
      	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:917)
      	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1001)
      	at com.liferay.registry.internal.RegistryImpl.registerService(RegistryImpl.java:305)
      	at com.liferay.portal.servlet.MainServlet.registerPortalInitialized(MainServlet.java:1337)
      	at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:424)
      	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
      	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1238)
      	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1151)
      	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1038)
      	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4997)
      	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5289)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
      	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
      	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
      	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:585)
      	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: com.liferay.portal.kernel.upgrade.UpgradeException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:92)
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:123)
      	at com.liferay.portal.upgrade.internal.release.ReleaseManagerOSGiCommands$UpgradeInfosRunnable.run(ReleaseManagerOSGiCommands.java:469)
      	... 94 more
      Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
      	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
      	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
      	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
      	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
      	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
      	at com.liferay.portal.dao.orm.hibernate.event.NestableFlushEventListener.onFlush(NestableFlushEventListener.java:61)
      	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
      	at com.liferay.portal.spring.hibernate.PortletTransactionManager$TransactionStatusWrapper.reset(PortletTransactionManager.java:259)
      	at com.liferay.portal.spring.hibernate.PortletTransactionManager.commit(PortletTransactionManager.java:63)
      	at com.liferay.portal.spring.transaction.DefaultTransactionExecutor._commit(DefaultTransactionExecutor.java:128)
      	at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.commit(DefaultTransactionExecutor.java:36)
      	at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
      	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.RetryAdvice.invoke(RetryAdvice.java:46)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.service.ServiceContextAdvice.invoke(ServiceContextAdvice.java:39)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.cache.thread.local.ThreadLocalCacheAdvice.invoke(ThreadLocalCacheAdvice.java:51)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
      	at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:174)
      	at com.sun.proxy.$Proxy415.addTemplateLink(Unknown Source)
      	at com.liferay.portal.workflow.kaleo.forms.internal.upgrade.v1_0_2.UpgradeKaleoProcessTemplateLink.updateKaleoProcess(UpgradeKaleoProcessTemplateLink.java:60)
      	at com.liferay.portal.workflow.kaleo.forms.internal.upgrade.v1_0_2.UpgradeKaleoProcessTemplateLink.doUpgrade(UpgradeKaleoProcessTemplateLink.java:42)
      	at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:89)
      	... 96 more
      Caused by: java.sql.BatchUpdateException: integrity constraint violation: unique constraint or index violation: IX_6F3B3E9C
      	at org.hsqldb.jdbc.JDBCPreparedStatement.executeBatch(JDBCPreparedStatement.java:1937)
      	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
      	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
      	... 135 more
      

      Kaleo Forms Admin is no longer displayed in the Product menu as a result.

      Reproduced in
      master?
      Not applicable to master as master seems to lack the Kaleo Upgrade classes
      ee-7.0.x?
      Yes, issue reproduced in ee-7.0.x (b1a2dc839642f9c49eb16cc8885421ccdb2e75c8)

      1. pr-23.sql
        1.37 MB
        Adam Brandizzi

        Activity

        Hide
        michael.prigge Michael Prigge added a comment -

        Just started reviewing MichaelPrigge/liferay-portal-ee#177.


        Sent from GH

        Show
        michael.prigge Michael Prigge added a comment - Just started reviewing MichaelPrigge/liferay-portal-ee#177 . Sent from GH
        Hide
        marcellus.tavares Marcellus Tavares added a comment -

        Just started reviewing


        Sent from GH

        Show
        marcellus.tavares Marcellus Tavares added a comment - Just started reviewing Sent from GH
        Hide
        adam.brandizzi Adam Brandizzi added a comment -

        Just started reviewing brandizzi/liferay-portal-ee#23.


        Sent from GH

        Show
        adam.brandizzi Adam Brandizzi added a comment - Just started reviewing brandizzi/liferay-portal-ee#23 . Sent from GH
        Hide
        adam.brandizzi Adam Brandizzi added a comment -

        Just started reviewing brandizzi/liferay-portal-ee#23.


        Sent from GH

        Show
        adam.brandizzi Adam Brandizzi added a comment - Just started reviewing brandizzi/liferay-portal-ee#23 . Sent from GH
        Hide
        adam.brandizzi Adam Brandizzi added a comment -

        Pull request submitted to inacionery/liferay-portal-ee#26.


        Sent from GH

        Show
        adam.brandizzi Adam Brandizzi added a comment - Pull request submitted to inacionery/liferay-portal-ee#26 . Sent from GH
        Hide
        inacio.nery Inácio Nery added a comment -

        Just started reviewing inacionery/liferay-portal-ee#26.


        Sent from GH

        Show
        inacio.nery Inácio Nery added a comment - Just started reviewing inacionery/liferay-portal-ee#26 . Sent from GH
        Hide
        adam.brandizzi Adam Brandizzi added a comment - - edited

        Hello Michael Bowerman!

        I tested this fix but the upgrade seems to be still failing. Your changes are right but it appears that they should be also applied to updateKaleoProcessLink(). Could you take a look? The attachment pr-23.sql contains the dump of the database I tried to upgrade right after creating the form in SP1, with no upgrade applied.

        Could you double check if it is really failing? I wonder if I missed something.
        If so, let me know! Thanks!

        Show
        adam.brandizzi Adam Brandizzi added a comment - - edited Hello Michael Bowerman ! I tested this fix but the upgrade seems to be still failing. Your changes are right but it appears that they should be also applied to updateKaleoProcessLink() . Could you take a look? The attachment pr-23.sql contains the dump of the database I tried to upgrade right after creating the form in SP1, with no upgrade applied. Could you double check if it is really failing? I wonder if I missed something. If so, let me know! Thanks!
        Hide
        melody.wu Melody Wu added a comment -

        PASSED Manual Testing following the steps in the description.

        Fixed on:
        Upgrade From: 7.0.10 EE SP1.
        Tomcat 8.0.32 + MySQL 5.6. Portal ee-7.0.x GIT ID: b3c98cc89aa1140bb07ba9463b0fab7555d1e826.

        The module upgrades for Kaleo complete with no errors.

        Show
        melody.wu Melody Wu added a comment - PASSED Manual Testing following the steps in the description. Fixed on: Upgrade From: 7.0.10 EE SP1. Tomcat 8.0.32 + MySQL 5.6. Portal ee-7.0.x GIT ID: b3c98cc89aa1140bb07ba9463b0fab7555d1e826. The module upgrades for Kaleo complete with no errors.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              5 days ago

              Development

                Subcomponents