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

DB deadlock if user edits issue when project is being analyzed

    XMLWordPrintable

    Details

    • Edition:
      Community
    • Production Notes:
      None

      Description

      Editing an issue from web API, for example marking it as won't fix, makes analysis fail if it is processed at the same time by Compute Engine. Both Web Service and Compute Engine update the rows of table live_measures at the same time :

      org.sonar.ce.task.projectanalysis.component.VisitException: Visit of Component {key=org.sonarsource.sonarqube:sonar-plugin-api,uuid=7feef7c3-11b9-4175-b5a7-527ca3c75cb7,type=MODULE} failed
      	at org.sonar.ce.task.projectanalysis.component.VisitException.rethrowOrWrap(VisitException.java:44)
      	at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:41)
      	at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:98)
      	at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:54)
      	at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39)
      	at org.sonar.ce.task.projectanalysis.step.PersistLiveMeasuresStep.execute(PersistLiveMeasuresStep.java:91)
      	at org.sonar.ce.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:69)
      	at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:55)
      	at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:81)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.executeTask(CeWorkerImpl.java:136)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:99)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.withCustomizedThreadName(CeWorkerImpl.java:83)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:75)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:45)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.apache.ibatis.exceptions.PersistenceException: 
      ### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: deadlock detected
        Detail: Process 20838 waits for ShareLock on transaction 7656488; blocked by process 26014.
      Process 26014 waits for ShareLock on transaction 7656483; blocked by process 20838.
        Hint: See server log for query details.
        Where: while updating tuple (229090,2) in relation "live_measures"
      ### The error may involve org.sonar.db.measure.LiveMeasureMapper.update-Inline
      ### The error occurred while setting parameters
      ### Cause: org.postgresql.util.PSQLException: ERROR: deadlock detected
        Detail: Process 20838 waits for ShareLock on transaction 7656488; blocked by process 26014.
      Process 26014 waits for ShareLock on transaction 7656483; blocked by process 20838.
        Hint: See server log for query details.
        Where: while updating tuple (229090,2) in relation "live_measures"
      	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
      	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
      	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
      	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
      	at com.sun.proxy.$Proxy70.update(Unknown Source)
      	at org.sonar.db.measure.LiveMeasureDao.insertOrUpdate(LiveMeasureDao.java:103)
      	at org.sonar.ce.task.projectanalysis.step.PersistLiveMeasuresStep$MeasureVisitor.visitAny(PersistLiveMeasuresStep.java:129)
      	at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitNode(DepthTraversalTypeAwareCrawler.java:67)
      	at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:51)
      	at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39)
      	... 20 more
      Caused by: org.postgresql.util.PSQLException: ERROR: deadlock detected
        Detail: Process 20838 waits for ShareLock on transaction 7656488; blocked by process 26014.
      Process 26014 waits for ShareLock on transaction 7656483; blocked by process 20838.
        Hint: See server log for query details.
        Where: while updating tuple (229090,2) in relation "live_measures"
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
      	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
      	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
      	at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:144)
      	at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
      	at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
      	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
      	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
      	at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:52)
      	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
      	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
      	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
      	... 28 more
      

      Another error related to portfolios raised by integration test "PortfoliosPageTest. portfolios_page" :

      2018.08.28 02:02:23 INFO  web[AWV9vMhAfsKwv3PsABJj][com.A.B.L.E.A] Triggering refresh of the following portfolios/applications: XOO (XOO)
      2018.08.28 02:02:53 INFO  web[AWV9vMhAfsKwv3PsABK4][com.A.B.L.E.A] Triggering refresh of the following portfolios/applications: XOO1 (XOO1)
      2018.08.28 02:02:56 INFO  web[AWV9vMhAfsKwv3PsABK/][com.A.B.L.E.A] Triggering refresh of the following portfolios/applications: XOO1 (XOO1), XOO2 (XOO2)
      2018.08.28 02:03:16 INFO  web[AWV9vMhAfsKwv3PsABL3][com.A.B.L.E.A] Triggering refresh of the following portfolios/applications: XOO1 (XOO1), XOO2 (XOO2)
      2018.08.28 02:03:19 INFO  web[AWV9vMhAfsKwv3PsABL+][com.A.B.L.E.A] Triggering refresh of the following portfolios/applications: XOO1 (XOO1), XOO2 (XOO2)
      2018.08.28 02:03:45 INFO  web[AWV9vMhAfsKwv3PsABNb][com.A.B.L.E.A] Triggering refresh of the following portfolios/applications: All Projects (MASTER_PROJECT), Apache (APACHE)
      2018.08.28 02:03:46 ERROR web[AWV9vMhAfsKwv3PsABNc][o.s.s.w.WebServiceEngine] Fail to process request http://127.0.0.1:28685/api/projects/delete
      org.apache.ibatis.exceptions.PersistenceException: 
      ### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
      ### The error may involve defaultParameterMap
      ### The error occurred while setting parameters
      ### SQL: delete from live_measures where project_uuid = ?
      ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
      	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
      	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
      	at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:213)
      	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68)
      	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
      	at com.sun.proxy.$Proxy57.deleteLiveMeasuresByProjectUuid(Unknown Source)
      	at org.sonar.db.purge.PurgeCommands.deleteLiveMeasures(PurgeCommands.java:317)
      	at org.sonar.db.purge.PurgeDao.deleteRootComponent(PurgeDao.java:208)
      	at org.sonar.db.purge.PurgeDao.deleteProject(PurgeDao.java:185)
      	at org.sonar.server.component.ComponentCleanerService.delete(ComponentCleanerService.java:63)
      	at org.sonar.server.project.ws.DeleteAction.handle(DeleteAction.java:94)
      	at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:110)
      	at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:88)
      	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.CacheControlFilter.doFilter(CacheControlFilter.java:76)
      	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:76)
      	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)
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
      	at com.mysql.jdbc.Util.getInstance(Util.java:408)
      	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:952)
      	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
      	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
      	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
      	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
      	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
      	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
      	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1197)
      	at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
      	at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
      	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
      	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
      	at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:52)
      	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
      	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
      	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
      	... 54 common frames omitted
      2018.08.28 02:05:47 WARN  web[AWV9vMhAfsKwv3PsABSu][governance] Project com.sonarsource.governance.samples:sample1 referenced in portfolio 'CODEHAUS' not found
      2018.08.28 02:07:53 WARN  web[AWV9vMhAfsKwv3PsABWk][governance] Project xoo-sample1 referenced in portfolio 'VIEW_ERROR' not found
      2018.08.28 02:07:53 WARN  web[AWV9vMhAfsKwv3PsABWk][governance] Project xoo-sample2 referenced in portfolio 'VIEW_WARNING' not found
      2018.08.28 02:07:53 WARN  web[AWV9vMhAfsKwv3PsABWk][governance] Project xoo:sample3 referenced in portfolio 'VIEW_OK' not found
      2018.08.28 02:08:28 INFO  web[AWV9vMhAfsKwv3PsABYX][o.a.f.a.FOUserAgent] Rendered page #1.
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              eric.hartmann Eric Hartmann
              Reporter:
              simon.brandhof Simon Brandhof (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: