Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-10532

Authentication can fail with "org.apache.ibatis.exceptions.TooManyResultsException"

    Details

      Description

      Use case

      • A new user try to authenticate with a identity provider "P1" but the server was too slow to finish
      • He then authenticates with another identity provider "P2" (using same email as P1), this time server is able to finish.

      Next time the user will try to authenticate it will fail, and the server stacktrace will contain :

      2018.03.26 03:07:30 ERROR web[AWIkiTsm8PZRszLNFQuL][o.s.s.a.AuthenticationError] Fail to callback authentication with 'github'
      org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:81)
              at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
              at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
              at com.sun.proxy.$Proxy52.selectByEmail(Unknown Source)
              at org.sonar.db.user.UserDao.selectByEmail(UserDao.java:165)
              at org.sonar.server.authentication.UserIdentityAuthenticator.validateEmail(UserIdentityAuthenticator.java:140)
              at org.sonar.server.authentication.UserIdentityAuthenticator.registerExistingUser(UserIdentityAuthenticator.java:109)
              at org.sonar.server.authentication.UserIdentityAuthenticator.authenticate(UserIdentityAuthenticator.java:96)
              at org.sonar.server.authentication.OAuth2ContextFactory$OAuthContextImpl.authenticate(OAuth2ContextFactory.java:130)
              at org.sonar.server.authentication.OAuth2CallbackFilter$WrappedContext.authenticate(OAuth2CallbackFilter.java:161)
              at org.sonarsource.auth.github.GitHubIdentityProvider.onCallback(GitHubIdentityProvider.java:137)
              at org.sonarsource.auth.github.GitHubIdentityProvider.callback(GitHubIdentityProvider.java:107)
              at org.sonar.server.authentication.OAuth2CallbackFilter.handleOAuth2Provider(OAuth2CallbackFilter.java:96)
              at org.sonar.server.authentication.OAuth2CallbackFilter.handleProvider(OAuth2CallbackFilter.java:76)
              at org.sonar.server.authentication.OAuth2CallbackFilter.doFilter(OAuth2CallbackFilter.java:69)
              at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126)
              at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:95)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:87)
              at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:71)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.SecurityServletFilter.doHttpFilter(SecurityServletFilter.java:72)
              at org.sonar.server.platform.web.SecurityServletFilter.doFilter(SecurityServletFilter.java:48)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.RedirectFilter.doFilter(RedirectFilter.java:61)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.requestid.RequestIdFilter.doFilter(RequestIdFilter.java:63)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:62)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
              at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
              at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
              at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
              at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
              at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
              at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
              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)
      

      Idea

      As for SONAR-10506, decreasing the time to create a user (And setting the user as "Under creation") should prevent decrease the time this issue happen.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julien.lancelot Julien Lancelot
                Reporter:
                julien.lancelot Julien Lancelot
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: