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

Logging in via LDAP in parallel causes StaleObjectStateException

    Details

    • Type: Bug
    • Status: Verified
    • Resolution: Unresolved
    • Affects Version/s: 7.2.X, Master
    • Fix Version/s: None
    • Labels:
      None

      Description

      Steps To Reproduce

      1. Start a Docker container with OpenLDAP installed and a password policy with history enabled.
        docker run --name LPS-76332 --detach -p 389:389 holatuwol/liferayissue:LPS-76332
        docker exec LPS-76332 ldapmodify -x -c -D 'cn=admin,cn=config' -w admin -f /postmodify.ldif
        
      2. Start up Liferay and log in as the admin user
      3. Navigate to Control Panel > Configuration > Instance Settings > LDAP
      4. Under "General" enable "Enabled"
      5. Under "Import" enable "Enable Import" and "Enable Import on Startup"
      6. Under "Server" add a server with the following details
        1. Set the name to "localhost"
        2. Select the OpenLDAP radio button
        3. Change the Base DN to "dc=example,dc=org"
        4. Change the Principal to "cn=test,ou=people,dc=example,dc=org"
        5. Change the password to "test"
        6. Click on the "Test LDAP Connection" button
      7. Test the LDAP user import
        1. Click on the "Test LDAP Users" button
      8. Save the configuration
      9. Wait for the users to be imported or restart the server to trigger it
      10. Add a new Service Access Policy under Control Panel - Security - Service Access Policy
        1. Name - Test
        2. Enabled - True
        3. Default - True
        4. Title - Test
        5. Service Class - *
        6. Method Name - *
      11. Open a new shell window, and run the following script. If not using the provided OpenLDAP server, update the value for -u accordingly.
        while true
        do
            curl http://localhost:8080/api/jsonws/classname/fetch-class-name -u 'test2@liferay.com:test' -d 'value=com.liferay.portal.kernel.model.User' 2>&1 | grep 'Exception'
        done
        
      12. Confirm that the script successfully runs successfully
      13. Open a new shell window, and run the above script again (essentially having two shell windows running the script in parallel)

      Expected Results
      There are no errors in the logs.

      Actual Results
      The following error appears several times in the logs:

      2020-06-26 21:16:05.007 ERROR [http-nio-8080-exec-10][LDAPUserImporterImpl:1193] Unable to import user 36254
      com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: {"agreedToTermsOfUse":false,"comments":"","companyId":"20098","contactId":"36255","createDate":1593206089978,"ctCollectionId":"0","defaultUser":false,"emailAddress":"","emailAddressVerified":true,"externalReferenceCode":"","facebookId":"0","failedLoginAttempts":0,"firstName":"Seven","googleUserId":"","graceLoginCount":0,"greeting":"Welcome Seven Test!","jobTitle":"","languageId":"en_US","lastFailedLoginDate":null,"lastLoginDate":null,"lastLoginIP":"","lastName":"Test","ldapServerId":"36125","lockout":false,"lockoutDate":null,"loginDate":null,"loginIP":"","middleName":"","modifiedDate":1593195434000,"mvccVersion":"40","openId":"","portraitId":"0","reminderQueryAnswer":"","reminderQueryQuestion":"","screenName":"test7","status":0,"timeZoneId":"UTC","userId":"36254","uuid":"6c61b99d-4d46-ae60-625f-a8e661eef5fb"} is stale in comparison to {"agreedToTermsOfUse":false,"comments":"","companyId":"20098","contactId":"36255","createDate":1593206089978,"ctCollectionId":"0","defaultUser":false,"emailAddress":"","emailAddressVerified":true,"externalReferenceCode":"","facebookId":"0","failedLoginAttempts":0,"firstName":"Seven","googleUserId":"","graceLoginCount":0,"greeting":"Welcome Seven Test!","jobTitle":"","languageId":"en_US","lastFailedLoginDate":null,"lastLoginDate":null,"lastLoginIP":"","lastName":"Test","ldapServerId":"36125","lockout":false,"lockoutDate":null,"loginDate":null,"loginIP":"","middleName":"","modifiedDate":1593206164853,"mvccVersion":"41","openId":"","portraitId":"0","reminderQueryAnswer":"","reminderQueryQuestion":"","screenName":"test7","status":0,"timeZoneId":"UTC","userId":"36254","uuid":"6c61b99d-4d46-ae60-625f-a8e661eef5fb"}
      	at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:564)
      	at com.liferay.portal.service.persistence.impl.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:8854)
      	at com.liferay.portal.service.persistence.impl.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:85)
      	at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.update(BasePersistenceImpl.java:666)
      	at com.liferay.portal.service.impl.UserLocalServiceImpl.updatePassword(UserLocalServiceImpl.java:4785)
      	at sun.reflect.GeneratedMethodAccessor345.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
      	at com.sun.proxy.$Proxy887.updatePassword(Unknown Source)
      	at com.liferay.portal.kernel.service.UserLocalServiceWrapper.updatePassword(UserLocalServiceWrapper.java:3167)
      	at sun.reflect.GeneratedMethodAccessor345.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
      	at com.sun.proxy.$Proxy888.updatePassword(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor345.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
      	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
      	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
      	at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
      	at com.sun.proxy.$Proxy77.updatePassword(Unknown Source)
      	at com.liferay.portal.security.ldap.internal.exportimport.LDAPUserImporterImpl.updateUserPassword(LDAPUserImporterImpl.java:1795)
      	at com.liferay.portal.security.ldap.internal.exportimport.LDAPUserImporterImpl.updateUser(LDAPUserImporterImpl.java:1700)
      	at com.liferay.portal.security.ldap.internal.exportimport.LDAPUserImporterImpl.importUser(LDAPUserImporterImpl.java:1168)
      	at com.liferay.portal.security.ldap.internal.exportimport.LDAPUserImporterImpl.importUser(LDAPUserImporterImpl.java:187)
      	at com.liferay.portal.security.ldap.internal.authenticator.LDAPAuth.authenticate(LDAPAuth.java:384)
      	at com.liferay.portal.security.ldap.internal.authenticator.LDAPAuth.authenticateAgainstPreferredLDAPServer(LDAPAuth.java:590)
      	at com.liferay.portal.security.ldap.internal.authenticator.LDAPAuth.authenticate(LDAPAuth.java:493)
      	at com.liferay.portal.security.ldap.internal.authenticator.LDAPAuth.authenticateByEmailAddress(LDAPAuth.java:99)
      	at com.liferay.portal.security.auth.AuthPipeline._authenticate(AuthPipeline.java:146)
      	at com.liferay.portal.security.auth.AuthPipeline.authenticateByEmailAddress(AuthPipeline.java:39)
      	at com.liferay.portal.service.impl.UserLocalServiceImpl.authenticate(UserLocalServiceImpl.java:5517)
      	at com.liferay.portal.service.impl.UserLocalServiceImpl.authenticateByEmailAddress(UserLocalServiceImpl.java:1257)
      	at sun.reflect.GeneratedMethodAccessor344.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
      	at com.sun.proxy.$Proxy887.authenticateByEmailAddress(Unknown Source)
      	at com.liferay.portal.kernel.service.UserLocalServiceWrapper.authenticateByEmailAddress(UserLocalServiceWrapper.java:439)
      	at sun.reflect.GeneratedMethodAccessor344.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
      	at com.sun.proxy.$Proxy888.authenticateByEmailAddress(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor344.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
      	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
      	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
      	at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
      	at com.sun.proxy.$Proxy77.authenticateByEmailAddress(Unknown Source)
      	at com.liferay.portal.kernel.service.UserLocalServiceUtil.authenticateByEmailAddress(UserLocalServiceUtil.java:437)
      	at com.liferay.portal.security.auth.session.AuthenticatedSessionManagerImpl._getAuthenticatedUser(AuthenticatedSessionManagerImpl.java:493)
      	at com.liferay.portal.security.auth.session.AuthenticatedSessionManagerImpl.getAuthenticatedUserId(AuthenticatedSessionManagerImpl.java:76)
      	at com.liferay.portal.kernel.security.auth.session.AuthenticatedSessionManagerUtil.getAuthenticatedUserId(AuthenticatedSessionManagerUtil.java:40)
      	at com.liferay.portal.security.auth.http.HttpAuthManagerImpl.getBasicUserId(HttpAuthManagerImpl.java:275)
      	at com.liferay.portal.security.auth.http.HttpAuthManagerImpl.getUserId(HttpAuthManagerImpl.java:163)
      	at com.liferay.portal.kernel.security.auth.http.HttpAuthManagerUtil.getUserId(HttpAuthManagerUtil.java:56)
      	at com.liferay.portal.security.auto.login.basic.auth.header.BasicAuthHeaderAutoLoginSupport.doLogin(BasicAuthHeaderAutoLoginSupport.java:73)
      	at com.liferay.portal.kernel.security.auto.login.BaseAutoLogin.login(BaseAutoLogin.java:38)
      	at com.liferay.portal.security.auth.verifier.internal.basic.auth.header.BasicAuthHeaderAuthVerifier.verify(BasicAuthHeaderAuthVerifier.java:56)
      	at com.liferay.portal.security.auth.AuthVerifierPipeline._verifyRequest(AuthVerifierPipeline.java:280)
      	at com.liferay.portal.security.auth.AuthVerifierPipeline.verifyRequest(AuthVerifierPipeline.java:74)
      	at com.liferay.portal.security.access.control.AccessControlImpl.verifyRequest(AccessControlImpl.java:96)
      	at com.liferay.portal.kernel.security.access.control.AccessControlUtil.verifyRequest(AccessControlUtil.java:100)
      	at com.liferay.portal.servlet.filters.authverifier.AuthVerifierFilter.processFilter(AuthVerifierFilter.java:147)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      	at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:62)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      	at com.liferay.portal.servlet.filters.lockout.LockoutFilter.processFilter(LockoutFilter.java:58)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)
      	at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)
      	at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:250)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
      	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
      	at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
      	at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
      	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
      	at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:104)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: com.liferay.portal.kernel.dao.orm.ORMException: {"agreedToTermsOfUse":false,"comments":"","companyId":"20098","contactId":"36255","createDate":1593206089978,"ctCollectionId":"0","defaultUser":false,"emailAddress":"","emailAddressVerified":true,"externalReferenceCode":"","facebookId":"0","failedLoginAttempts":0,"firstName":"Seven","googleUserId":"","graceLoginCount":0,"greeting":"Welcome Seven Test!","jobTitle":"","languageId":"en_US","lastFailedLoginDate":null,"lastLoginDate":null,"lastLoginIP":"","lastName":"Test","ldapServerId":"36125","lockout":false,"lockoutDate":null,"loginDate":null,"loginIP":"","middleName":"","modifiedDate":1593195434000,"mvccVersion":"40","openId":"","portraitId":"0","reminderQueryAnswer":"","reminderQueryQuestion":"","screenName":"test7","status":0,"timeZoneId":"UTC","userId":"36254","uuid":"6c61b99d-4d46-ae60-625f-a8e661eef5fb"} is stale in comparison to {"agreedToTermsOfUse":false,"comments":"","companyId":"20098","contactId":"36255","createDate":1593206089978,"ctCollectionId":"0","defaultUser":false,"emailAddress":"","emailAddressVerified":true,"externalReferenceCode":"","facebookId":"0","failedLoginAttempts":0,"firstName":"Seven","googleUserId":"","graceLoginCount":0,"greeting":"Welcome Seven Test!","jobTitle":"","languageId":"en_US","lastFailedLoginDate":null,"lastLoginDate":null,"lastLoginIP":"","lastName":"Test","ldapServerId":"36125","lockout":false,"lockoutDate":null,"loginDate":null,"loginIP":"","middleName":"","modifiedDate":1593206164853,"mvccVersion":"41","openId":"","portraitId":"0","reminderQueryAnswer":"","reminderQueryQuestion":"","screenName":"test7","status":0,"timeZoneId":"UTC","userId":"36254","uuid":"6c61b99d-4d46-ae60-625f-a8e661eef5fb"}
      	at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:67)
      	at com.liferay.portal.dao.orm.hibernate.SessionImpl.merge(SessionImpl.java:296)
      	at com.liferay.portal.service.persistence.impl.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:8850)
      	... 125 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#36254]
      	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:293)
      	... 126 more
      

      Note
      This issue was previously resolved under LPS-85179 however it has returned.

        Attachments

          Activity

            People

            • Assignee:
              support-lep@liferay.com SE Support
              Reporter:
              jonathan.mccann Jonathan McCann
              Participants of an Issue:
              Recent user:
              Stian Sigvartsen
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                5 weeks, 5 days ago

                Packages

                Version Package