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

Unable to update entities in non default shards: mvccVersion control doesn't allow it

    Details

      Description

      Steps to reproduce it:
      1- Configure the portal to use sharding with at least two shards
      2- Startup the portal
      3- Create a new instance from control panel
      4- Log in that new instance and register the new user
      5- The following exception is displayed:

      11:21:03,686 ERROR [http-bio-8080-exec-8][MainServlet:473] com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: {mvccVersion=0, uuid=605bd838-8577-4ec4-ad76-08d368f35ce5, userId=10476, companyId=10436, createDate=Tue Apr 15 16:56:34 GMT 2014, modifiedDate=Tue Apr 15 16:56:34 GMT 2014, defaultUser=false, contactId=10477, password=qUqP5cyxm6YcTAhz05Hph5gvu9M=, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=null, digest=c8cac39c720c3f019fb52d3bc8c4556f,751da756639bc033b572ba2e7849b589,e78f7fee090c3b575b7d1bcb98fad9b6, reminderQueryQuestion=, reminderQueryAnswer=, graceLoginCount=0, screenName=test, emailAddress=test@liferay2.com, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=en_US, timeZoneId=GMT, greeting=Welcome Test Test!, comments=, firstName=Test, middleName=, lastName=Test, jobTitle=, loginDate=Wed Apr 16 11:21:03 GMT 2014, loginIP=127.0.0.1, lastLoginDate=Tue Apr 15 16:56:34 GMT 2014, lastLoginIP=127.0.0.1, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=true, status=0} is stale in comparison to {mvccVersion=1, uuid=605bd838-8577-4ec4-ad76-08d368f35ce5, userId=10476, companyId=10436, createDate=2014-04-15 16:56:34.0, modifiedDate=2014-04-15 16:56:34.0, defaultUser=false, contactId=10477, password=qUqP5cyxm6YcTAhz05Hph5gvu9M=, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=null, digest=c8cac39c720c3f019fb52d3bc8c4556f,751da756639bc033b572ba2e7849b589,e78f7fee090c3b575b7d1bcb98fad9b6, reminderQueryQuestion=, reminderQueryAnswer=, graceLoginCount=0, screenName=test, emailAddress=test@liferay2.com, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=en_US, timeZoneId=GMT, greeting=Welcome Test Test!, comments=, firstName=Test, middleName=, lastName=Test, jobTitle=, loginDate=2014-04-15 16:56:34.0, loginIP=, lastLoginDate=2014-04-15 16:56:34.0, lastLoginIP=, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=true, status=0}
      com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: {mvccVersion=0, uuid=605bd838-8577-4ec4-ad76-08d368f35ce5, userId=10476, companyId=10436, createDate=Tue Apr 15 16:56:34 GMT 2014, modifiedDate=Tue Apr 15 16:56:34 GMT 2014, defaultUser=false, contactId=10477, password=qUqP5cyxm6YcTAhz05Hph5gvu9M=, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=null, digest=c8cac39c720c3f019fb52d3bc8c4556f,751da756639bc033b572ba2e7849b589,e78f7fee090c3b575b7d1bcb98fad9b6, reminderQueryQuestion=, reminderQueryAnswer=, graceLoginCount=0, screenName=test, emailAddress=test@liferay2.com, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=en_US, timeZoneId=GMT, greeting=Welcome Test Test!, comments=, firstName=Test, middleName=, lastName=Test, jobTitle=, loginDate=Wed Apr 16 11:21:03 GMT 2014, loginIP=127.0.0.1, lastLoginDate=Tue Apr 15 16:56:34 GMT 2014, lastLoginIP=127.0.0.1, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=true, status=0} is stale in comparison to {mvccVersion=1, uuid=605bd838-8577-4ec4-ad76-08d368f35ce5, userId=10476, companyId=10436, createDate=2014-04-15 16:56:34.0, modifiedDate=2014-04-15 16:56:34.0, defaultUser=false, contactId=10477, password=qUqP5cyxm6YcTAhz05Hph5gvu9M=, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=null, digest=c8cac39c720c3f019fb52d3bc8c4556f,751da756639bc033b572ba2e7849b589,e78f7fee090c3b575b7d1bcb98fad9b6, reminderQueryQuestion=, reminderQueryAnswer=, graceLoginCount=0, screenName=test, emailAddress=test@liferay2.com, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=en_US, timeZoneId=GMT, greeting=Welcome Test Test!, comments=, firstName=Test, middleName=, lastName=Test, jobTitle=, loginDate=2014-04-15 16:56:34.0, loginIP=, lastLoginDate=2014-04-15 16:56:34.0, lastLoginIP=, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=true, status=0}
      	at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:253)
      	at com.liferay.portal.service.persistence.impl.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:6950)
      	at com.liferay.portal.service.persistence.impl.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:1)
      	at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.update(BasePersistenceImpl.java:335)
      	at sun.reflect.GeneratedMethodAccessor234.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:320)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      	at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:104)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      	at $Proxy41.update(Unknown Source)
      	at com.liferay.portal.service.impl.UserLocalServiceImpl.updateLastLogin(UserLocalServiceImpl.java:4549)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
      	at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
      	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:55)
      	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
      	at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
      	at $Proxy65.updateLastLogin(Unknown Source)
      	at com.liferay.portal.service.UserLocalServiceUtil.updateLastLogin(UserLocalServiceUtil.java:3049)
      	at com.liferay.portal.servlet.MainServlet.loginUser(MainServlet.java:995)
      	at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:465)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
      	at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:360)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
      	at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:124)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
      	at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:293)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
      	at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
      	at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
      	at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:97)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:662)
      Caused by: com.liferay.portal.kernel.dao.orm.ORMException: {mvccVersion=0, uuid=605bd838-8577-4ec4-ad76-08d368f35ce5, userId=10476, companyId=10436, createDate=Tue Apr 15 16:56:34 GMT 2014, modifiedDate=Tue Apr 15 16:56:34 GMT 2014, defaultUser=false, contactId=10477, password=qUqP5cyxm6YcTAhz05Hph5gvu9M=, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=null, digest=c8cac39c720c3f019fb52d3bc8c4556f,751da756639bc033b572ba2e7849b589,e78f7fee090c3b575b7d1bcb98fad9b6, reminderQueryQuestion=, reminderQueryAnswer=, graceLoginCount=0, screenName=test, emailAddress=test@liferay2.com, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=en_US, timeZoneId=GMT, greeting=Welcome Test Test!, comments=, firstName=Test, middleName=, lastName=Test, jobTitle=, loginDate=Wed Apr 16 11:21:03 GMT 2014, loginIP=127.0.0.1, lastLoginDate=Tue Apr 15 16:56:34 GMT 2014, lastLoginIP=127.0.0.1, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=true, status=0} is stale in comparison to {mvccVersion=1, uuid=605bd838-8577-4ec4-ad76-08d368f35ce5, userId=10476, companyId=10436, createDate=2014-04-15 16:56:34.0, modifiedDate=2014-04-15 16:56:34.0, defaultUser=false, contactId=10477, password=qUqP5cyxm6YcTAhz05Hph5gvu9M=, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=null, digest=c8cac39c720c3f019fb52d3bc8c4556f,751da756639bc033b572ba2e7849b589,e78f7fee090c3b575b7d1bcb98fad9b6, reminderQueryQuestion=, reminderQueryAnswer=, graceLoginCount=0, screenName=test, emailAddress=test@liferay2.com, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=en_US, timeZoneId=GMT, greeting=Welcome Test Test!, comments=, firstName=Test, middleName=, lastName=Test, jobTitle=, loginDate=2014-04-15 16:56:34.0, loginIP=, lastLoginDate=2014-04-15 16:56:34.0, lastLoginIP=, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=true, status=0}
      	at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:46)
      	at com.liferay.portal.dao.orm.hibernate.SessionImpl.merge(SessionImpl.java:234)
      	at com.liferay.portal.kernel.dao.orm.ClassLoaderSession.merge(ClassLoaderSession.java:389)
      	at com.liferay.portal.service.persistence.impl.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:6946)
      	... 90 more
      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.liferay.portal.model.impl.UserImpl#10476]
      	at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:485)
      	at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:255)
      	at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
      	at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:867)
      	at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:851)
      	at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:855)
      	at com.liferay.portal.dao.orm.hibernate.SessionImpl.merge(SessionImpl.java:231)
      

      Explanation for the error: Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
      "You have optimistic locking configured on your entities, using an @Version annotated field. The principle of optimistic locking is to only allow an update of a row if the version stored in the row has the same value as the one stored in the entity being merged. Otherwise, the exception you get is thrown."

      Techinical Notes:
      The problem is that we put into the cache an entity after updating it but after that we modify the entity to increase the version field (mvccVersion field in Liferay) and we don't take into account the different shards to modifiy the cache in the porper shard, we always do it in the default shard. So next time we try to modify that entity the previous exception is displayed since the entity which we get for that shard has the mvccVersion field outdated.

      This issue has been brought to light by LPS-44425, before those changes we couldn't reproduce it since the cache wasn't working properly for non default shards (we always associated cache records to the default shard)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 42 weeks, 5 days ago

                  Packages

                  Version Package