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

Failure when analyzing a branch of a module that was removed from another project

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 6.7.2
    • Fix Version/s: None
    • Component/s: Branch & PR, Compute Engine
    • Labels:
      None
    • Edition:
      Developer

      Description

      Use case:

      • Analyze a project with a module moduleM
      • Analyze a long-lived branch branchB with the same module
      • Analyze again the master without the module
      • Update the key of the module to be able to analyze it as a new standalone project:
        curl -u admin:admin -X POST "http://localhost/api/projects/update_key?from=moduleM&to=moduleM-removed"
        
      • Analyze the module as a new standalone project moduleM
      • Analyze the module with the same long-lived branch name branchB
        (The idea is that the user extracts a sub-module to be a standalone project, and then probably wants to recreate the same branches for this project too, as the old one.)

      Scanner execution is in success, but the CE task fails:

      org.apache.ibatis.exceptions.PersistenceException: 
      ### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PROJECTS_KEE ON PUBLIC.PROJECTS(KEE) VALUES ( /* 610 */ 'moduleM:BRANCH:branchB' )"; SQL statement:
      INSERT INTO projects (
            organization_uuid,
            kee,
            deprecated_kee,
            uuid,
            uuid_path,
            project_uuid,
            module_uuid,
            module_uuid_path,
            main_branch_project_uuid,
            name,
            long_name,
            qualifier,
            scope,
            language,
            description,
            private,
            tags,
            root_uuid,
            path,
            copy_component_uuid,
            developer_uuid,
            enabled,
            created_at,
            b_changed,
            b_copy_component_uuid,
            b_description,
            b_enabled,
            b_language,
            b_long_name,
            b_module_uuid,
            b_module_uuid_path,
            b_name,
            b_path,
            b_qualifier
          )
          VALUES (
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          false,
          null,
          null,
          false,
          null,
          null,
          null,
          null,
          null,
          null,
          null
          ) [23505-176]
      	at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
      	at org.h2.message.DbException.get(DbException.java:178)
      	at org.h2.message.DbException.get(DbException.java:154)
      	at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103)
      	at org.h2.index.PageBtree.find(PageBtree.java:121)
      	at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:151)
      	at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:104)
      	at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:206)
      	at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:97)
      	at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:88)
      	at org.h2.table.RegularTable.addRow(RegularTable.java:120)
      	at org.h2.command.dml.Insert.insertRows(Insert.java:157)
      	at org.h2.command.dml.Insert.update(Insert.java:115)
      	at org.h2.command.CommandContainer.update(CommandContainer.java:79)
      	at org.h2.command.Command.executeUpdate(Command.java:254)
      	at org.h2.server.TcpServerThread.process(TcpServerThread.java:346)
      	at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
      	at java.lang.Thread.run(Thread.java:748)
      
      ### The error may involve org.sonar.db.component.ComponentMapper.insert-Inline
      ### The error occurred while setting parameters
      ### SQL: INSERT INTO projects (       organization_uuid,       kee,       deprecated_kee,       uuid,       uuid_path,       project_uuid,       module_uuid,       module_uuid_path,       main_branch_project_uuid,       name,       long_name,       qualifier,       scope,       language,       description,       private,       tags,       root_uuid,       path,       copy_component_uuid,       developer_uuid,       enabled,       created_at,       b_changed,       b_copy_component_uuid,       b_description,       b_enabled,       b_language,       b_long_name,       b_module_uuid,       b_module_uuid_path,       b_name,       b_path,       b_qualifier     )     VALUES (     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     ?,     false,     null,     null,     false,     null,     null,     null,     null,     null,     null,     null     )
      ### Cause: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PROJECTS_KEE ON PUBLIC.PROJECTS(KEE) VALUES ( /* 610 */ 'multi-language-multi-module-project:backend:BRANCH:branch-long' )"; SQL statement:
      INSERT INTO projects (
            organization_uuid,
            kee,
            deprecated_kee,
            uuid,
            uuid_path,
            project_uuid,
            module_uuid,
            module_uuid_path,
            main_branch_project_uuid,
            name,
            long_name,
            qualifier,
            scope,
            language,
            description,
            private,
            tags,
            root_uuid,
            path,
            copy_component_uuid,
            developer_uuid,
            enabled,
            created_at,
            b_changed,
            b_copy_component_uuid,
            b_description,
            b_enabled,
            b_language,
            b_long_name,
            b_module_uuid,
            b_module_uuid_path,
            b_name,
            b_path,
            b_qualifier
          )
          VALUES (
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          false,
          null,
          null,
          false,
          null,
          null,
          null,
          null,
          null,
          null,
          null
          ) [23505-176]
      	at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
      	at org.h2.message.DbException.get(DbException.java:178)
      	at org.h2.message.DbException.get(DbException.java:154)
      	at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103)
      	at org.h2.index.PageBtree.find(PageBtree.java:121)
      	at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:151)
      	at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:104)
      	at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:206)
      	at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:97)
      	at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:88)
      	at org.h2.table.RegularTable.addRow(RegularTable.java:120)
      	at org.h2.command.dml.Insert.insertRows(Insert.java:157)
      	at org.h2.command.dml.Insert.update(Insert.java:115)
      	at org.h2.command.CommandContainer.update(CommandContainer.java:79)
      	at org.h2.command.Command.executeUpdate(Command.java:254)
      	at org.h2.server.TcpServerThread.process(TcpServerThread.java:346)
      	at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
      	at java.lang.Thread.run(Thread.java:748)
      
      	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.insert(DefaultSqlSession.java:185)
      	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
      	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
      	at com.sun.proxy.$Proxy31.insert(Unknown Source)
      	at org.sonar.db.component.ComponentDao.insert(ComponentDao.java:326)
      	at org.sonar.server.computation.task.projectanalysis.component.BranchPersisterImpl.insertIntoProjectsTable(BranchPersisterImpl.java:102)
      	at org.sonar.server.computation.task.projectanalysis.component.BranchPersisterImpl.lambda$persist$0(BranchPersisterImpl.java:61)
      	at com.google.common.base.Absent.or(Absent.java:60)
      	at org.sonar.server.computation.task.projectanalysis.component.BranchPersisterImpl.persist(BranchPersisterImpl.java:61)
      	at org.sonar.server.computation.task.projectanalysis.step.PersistComponentsStep.execute(PersistComponentsStep.java:97)
      	at org.sonar.server.computation.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:64)
      	at org.sonar.server.computation.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:52)
      	at org.sonar.server.computation.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:73)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.executeTask(CeWorkerImpl.java:134)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:97)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.withCustomizedThreadName(CeWorkerImpl.java:81)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:73)
      	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:43)
      	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.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PROJECTS_KEE ON PUBLIC.PROJECTS(KEE) VALUES ( /* 610 */ 'multi-language-multi-module-project:backend:BRANCH:branch-long' )"; SQL statement:
      INSERT INTO projects (
            organization_uuid,
            kee,
            deprecated_kee,
            uuid,
            uuid_path,
            project_uuid,
            module_uuid,
            module_uuid_path,
            main_branch_project_uuid,
            name,
            long_name,
            qualifier,
            scope,
            language,
            description,
            private,
            tags,
            root_uuid,
            path,
            copy_component_uuid,
            developer_uuid,
            enabled,
            created_at,
            b_changed,
            b_copy_component_uuid,
            b_description,
            b_enabled,
            b_language,
            b_long_name,
            b_module_uuid,
            b_module_uuid_path,
            b_name,
            b_path,
            b_qualifier
          )
          VALUES (
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          ?,
          false,
          null,
          null,
          false,
          null,
          null,
          null,
          null,
          null,
          null,
          null
          ) [23505-176]
      	at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
      	at org.h2.message.DbException.get(DbException.java:178)
      	at org.h2.message.DbException.get(DbException.java:154)
      	at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103)
      	at org.h2.index.PageBtree.find(PageBtree.java:121)
      	at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:151)
      	at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:104)
      	at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:206)
      	at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:97)
      	at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:88)
      	at org.h2.table.RegularTable.addRow(RegularTable.java:120)
      	at org.h2.command.dml.Insert.insertRows(Insert.java:157)
      	at org.h2.command.dml.Insert.update(Insert.java:115)
      	at org.h2.command.CommandContainer.update(CommandContainer.java:79)
      	at org.h2.command.Command.executeUpdate(Command.java:254)
      	at org.h2.server.TcpServerThread.process(TcpServerThread.java:346)
      	at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
      	at java.lang.Thread.run(Thread.java:748)
      
      	at org.h2.engine.SessionRemote.done(SessionRemote.java:606)
      	at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:192)
      	at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:199)
      	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)
      	... 26 more
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                christophe.levis Christophe Levis
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: