Search code examples
jenkinssonarqubesonar-runnersonarqube-5.0sonarqube-4.5

Error during Sonar runner execution 5.0. "After migrating 3.7.4 to 5.0"


migrate my database to another scheme. And migrate from 3.7.4 to 5.0. So far so perfect.

Now when running scheduled tasks on jenkins, get this error:

17:47:35.275 INFO  - Store results in database
17:47:35.275 DEBUG - Execute org.sonar.batch.index.MeasurePersister
17:47:35.400 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@41ccdc4d[id=139867,key=7X24:7X24,qualifier=TRK], with key batch-7X24:7X24
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1:42.087s
Final Memory: 33M/815M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: Unable to save some measures
    at org.sonar.batch.index.MeasurePersister.persist(MeasurePersister.java:77)
    at org.sonar.batch.phases.PhaseExecutor.executePersisters(PhaseExecutor.java:163)
    at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:132)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:222)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:223)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:65)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:52)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:128)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
    at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:171)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    ... 9 more
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error committing transaction.  Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.api.database.model.MeasureMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: ORA-00001: restricción única (SONAR5.SYS_C0078055) violada

### Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.api.database.model.MeasureMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: ORA-00001: restricción única (SONAR5.SYS_C0078055) violada

    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:177)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:169)
    at org.sonar.core.persistence.DbSession.commit(DbSession.java:61)
    at org.sonar.core.persistence.BatchSession.commit(BatchSession.java:177)
    at org.sonar.core.persistence.BatchSession.increment(BatchSession.java:214)
    at org.sonar.core.persistence.BatchSession.insert(BatchSession.java:134)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
    at com.sun.proxy.$Proxy80.insert(Unknown Source)
    at org.sonar.batch.index.MeasurePersister.persist(MeasurePersister.java:71)
    ... 33 more
Caused by: org.apache.ibatis.executor.BatchExecutorException: org.sonar.api.database.model.MeasureMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: ORA-00001: restricción única (SONAR5.SYS_C0078055) violada

    at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:127)
    at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:114)
    at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:109)
    at org.apache.ibatis.executor.BaseExecutor.commit(BaseExecutor.java:201)
    at org.apache.ibatis.executor.CachingExecutor.commit(CachingExecutor.java:104)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:174)
    ... 42 more
Caused by: java.sql.BatchUpdateException: ORA-00001: restricción única (SONAR5.SYS_C0078055) violada

    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10500)
    at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:230)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:103)
    ... 47 more
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILURE

This is an index (SONAR5.SYS_C0078055).

CREATE UNIQUE INDEX "SONAR5"."SYS_C0078055" ON "SONAR5"."PROJECT_MEASURES" ("ID") PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SONAR5_DATA_S" ;

I do not understand the problem of error. Help. Thank.


Solution

  • You probably forgot to migrate sequences when changing SQ scheme. Ids for new measures are starting from 1 so that create duplicate ids.