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

Instance delete operation is creating some orphan entries in the SystemEvent table

Details

    Description

      The instance delete operation is creating some orphan entries in the SystemEvent table.

      The created entries are related to some groups of the company that was deleted.

      Root cause

      • The deleteGroup(Group group) method in the GroupLocalServiceImpl class deletes all the SystemEvent entries of the deleted group
      • But the deletion is done before the listeners are executed, so any deletion done in a GroupModelListener, will generate a orphan entry in the SystemEvent table

      Steps to reproduce

      1. Double check that there are no orphan entries in the SystemEvent table, executing this SQL:
        select * from SystemEvent where groupId not in (select groupId from Group_)
        
      2. Go to Control Panel => Virtual instances
      3. Create a new instance
      4. Once the instance is completely created, delete it
      5. Execute again the SQL of step 1:
        • Expected result: the SQL doesn't return any record
        • Wrong result: the SQL returns some records

      Additional Information

      This issue was detected by a failure of the CompanyLocalServiceTest integration test, see LRQA-70796

           [exec] com.liferay.company.service.test.CompanyLocalServiceTest > testAddAndDeleteCompany FAILED
           [exec]     java.lang.AssertionError: com.liferay.company.service.test.CompanyLocalServiceTest caused leftover data for class :com.liferay.portal.kernel.model.SystemEvent with data : [
           [exec]     	{"mvccVersion": 0, "ctCollectionId": 0, "systemEventId": 107358, "groupId": 104366, "companyId": 20100, "userId": 20128, "userName": "Test Test", "createDate": "2021-10-11 07:18:36.155", "classNameId": 29402, "classPK": 106594, "classUuid": "b2d53fa7-b29c-232a-a200-956d56288aa6", "referrerClassNameId": 0, "parentSystemEventId": 0, "systemEventSetKey": 107359, "type": 1, "extraData": ""} with backtrace info,
           [exec]     		Thread name : com.liferay.company.test-executor-thread, id : 523, created : {"mvccVersion": 0, "ctCollectionId": 0, "systemEventId": 107358, "groupId": 104366, "companyId": 20100, "userId": 20128, "userName": "Test Test", "createDate": "Mon Oct 11 07:18:36 GMT 2021", "classNameId": 29402, "classPK": 106594, "classUuid": "b2d53fa7-b29c-232a-a200-956d56288aa6", "referrerClassNameId": 0, "parentSystemEventId": 0, "systemEventSetKey": 107359, "type": 1, "extraData": ""} at 
           [exec]     java.lang.Exception
           [exec]     	at com.liferay.portal.kernel.test.rule.DataGuardTestRuleUtil$RecordingSessionWrapper._record(DataGuardTestRuleUtil.java:681)
           [exec]     	at com.liferay.portal.kernel.test.rule.DataGuardTestRuleUtil$RecordingSessionWrapper.save(DataGuardTestRuleUtil.java:640)
           [exec]     	at com.liferay.portal.service.persistence.impl.SystemEventPersistenceImpl.updateImpl(SystemEventPersistenceImpl.java:2633)
           [exec]     	at com.liferay.portal.service.persistence.impl.SystemEventPersistenceImpl.updateImpl(SystemEventPersistenceImpl.java:73)
           [exec]     	at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.update(BasePersistenceImpl.java:781)
           [exec]     	at com.liferay.portal.service.impl.SystemEventLocalServiceImpl.addSystemEvent(SystemEventLocalServiceImpl.java:266)
           [exec]     	at com.liferay.portal.service.impl.SystemEventLocalServiceImpl.addSystemEvent(SystemEventLocalServiceImpl.java:75)
           [exec]     	at sun.reflect.GeneratedMethodAccessor616.invoke(Unknown Source)
           [exec]     	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           [exec]     	at java.lang.reflect.Method.invoke(Method.java:498)
           [exec]     	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
           [exec]     	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
           [exec]     	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
           [exec]     	at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
           [exec]     	at com.sun.proxy.$Proxy55.addSystemEvent(Unknown Source)
           [exec]     	at com.liferay.portal.kernel.service.SystemEventLocalServiceUtil.addSystemEvent(SystemEventLocalServiceUtil.java:53)
           [exec]     	at com.liferay.portal.systemevent.SystemEventAdvice.afterReturning(SystemEventAdvice.java:135)
           [exec]     	at com.liferay.portal.kernel.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:66)
           [exec]     	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
           [exec]     	at com.liferay.portal.kernel.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:64)
           [exec]     	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
           [exec]     	at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
           [exec]     	at com.sun.proxy.$Proxy889.deleteLayoutPageTemplateEntry(Unknown Source)
           [exec]     	at com.liferay.layout.page.template.internal.model.listener.GroupModelListener.onBeforeRemove(GroupModelListener.java:72)
           [exec]     	at com.liferay.layout.page.template.internal.model.listener.GroupModelListener.onBeforeRemove(GroupModelListener.java:38)
           [exec]     	at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.remove(BasePersistenceImpl.java:663)
           [exec]     	at com.liferay.portal.service.impl.GroupLocalServiceImpl.deleteGroup(GroupLocalServiceImpl.java:1119)
           [exec]     	at sun.reflect.GeneratedMethodAccessor707.invoke(Unknown Source)
           [exec]     	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           [exec]     	at java.lang.reflect.Method.invoke(Method.java:498)
           [exec]     	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
           [exec]     	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
           [exec]     	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
           [exec]     	at com.liferay.portal.kernel.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:64)
           [exec]     	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
           [exec]     	at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
           [exec]     	at com.sun.proxy.$Proxy67.deleteGroup(Unknown Source)
           [exec]     	at com.liferay.portal.service.impl.CompanyLocalServiceImpl$DeleteGroupActionableDynamicQuery.deleteGroup(CompanyLocalServiceImpl.java:1736)

      Attachments

        Issue Links

          Activity

            People

              kevin.wan Kevin Wan
              jorge.diaz Jorge Diaz
              Kiyoshi Lee Kiyoshi Lee
              Jorge Diaz Jorge Diaz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                1 year, 23 weeks, 6 days ago

                Packages

                  Version Package
                  7.2.10 DXP FP17
                  7.2.10.6 DXP SP6
                  7.2.X
                  7.3.10.3 DXP SP3
                  7.3.X
                  7.4.13 DXP GA1
                  7.4.3.4 CE GA4
                  Master