Upgrade to 7.7 #2506 'Migrate quality gate conditions using warning, period and no more supported operations': failure

sonarqube

(Adrian) #1

SonarQube Enterprise 7.7
Databese Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit
Upgrade SonarQube from 6.7.6 to 7.7 SonarQube Enterprise 7.7

When I start upgrade database i got first error

ERROR web[][DbMigrations] #1907 'Populate table live_measures': failure

To resolve that i find solution here https://tutel.me/c/programming/questions/48666926/sonarqube+update+database+for+version+7+fails

but after resolve issue #1907 the application has thrown a new error

2019.03.25 14:50:55 INFO  web[][DbMigrations] #2506 'Migrate quality gate conditions using warning, period and no more supported operations'...
2019.03.25 14:50:55 ERROR web[][DbMigrations] #2506 'Migrate quality gate conditions using warning, period and no more supported operations': failure | time=78ms
2019.03.25 14:50:55 ERROR web[][DbMigrations] Executed DB migrations: failure | time=3215947ms
2019.03.25 14:50:55 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=3216027ms
2019.03.25 14:50:55 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration ended with an exception
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #2506 'Migrate quality gate conditions using warning, period and no more supported operations' failed
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:79)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:67)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:52)
        at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(MigrationEngineImpl.java:68)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(DatabaseMigrationImpl.java:105)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(DatabaseMigrationImpl.java:80)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Duplicate key major_violations
        at org.sonar.core.util.stream.MoreCollectors.putAndFailOnDuplicateKey(MoreCollectors.java:295)
        at org.sonar.core.util.stream.MoreCollectors.lambda$uniqueIndex$9(MoreCollectors.java:256)
        at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at org.sonar.server.platform.db.migration.version.v76.MigrateNoMoreUsedQualityGateConditions.markConditionsUsingLeakPeriodHavingAlreadyRelatedConditionAsToBeDeleted(MigrateNoMoreUsedQualityGateConditions.java:170)
        at org.sonar.server.platform.db.migration.version.v76.MigrateNoMoreUsedQualityGateConditions.execute(MigrateNoMoreUsedQualityGateConditions.java:109)
        at org.sonar.server.platform.db.migration.step.DataChange.execute(DataChange.java:45)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
        ... 9 common frames omitted

Unfortunately i cannot find any help to resolve that issue, Could you help with this error ?

Kind Regards
Adrian


(Julien Lancelot) #2

Hi,

First of all, from what I see in the link you’ve given, you have removed a unique index.
Tweaking the database is not at all a good idea, as even if it’s solving an issue at some point of time, it will bring you into much bigger trouble, and it will be really harder/impossible to help you.
So I would recommend you very much to re-create the unique index in table LIVE_MEASURES on columns COMPONENT_UUID and METRIC_ID.

Then, in order to fix this new issue, you should manually do the clean up in the Quality Gates administration page.
You should find everything you need in the MMF that was implemented do simplify the definition of Quality Gate : https://jira.sonarsource.com/browse/MMF-473

Regards,
Julien Lancelot


(Adrian) #3

Hi Julien and thanks for response,

Thanks for advice

Do you have any other proposition to resolve issue and do not droping Index ?

2019.03.25 13:52:39 ERROR web[][DbMigrations] #1907 'Populate table live_measures': failure | time=149673ms
2019.03.25 13:52:39 ERROR web[][DbMigrations] Executed DB migrations: failure | time=150560ms
2019.03.25 13:52:39 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=150720ms
2019.03.25 13:52:39 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration ended with an exception
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #1907 'Populate table live_measures' failed
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:79)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:67)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:52)
        at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(MigrationEngineImpl.java:68)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(DatabaseMigrationImpl.java:105)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(DatabaseMigrationImpl.java:80)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Error during processing of row: [uuid=AVTNVNBUobjp3nKU_brv,project_uuid=AVTNVNAYobjp3nKU_bqQ,metric_id=10137,value=70.7,text_value=null,variation_value_1=0,measure_data=null]
        at org.sonar.server.platform.db.migration.step.SelectImpl.newExceptionWithRowDetails(SelectImpl.java:89)
        at org.sonar.server.platform.db.migration.step.SelectImpl.scroll(SelectImpl.java:81)
        at org.sonar.server.platform.db.migration.step.MassUpdate.execute(MassUpdate.java:92)
        at org.sonar.server.platform.db.migration.version.v70.PopulateLiveMeasures.execute(PopulateLiveMeasures.java:57)
        at org.sonar.server.platform.db.migration.step.DataChange.execute(DataChange.java:45)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
        ... 9 common frames omitted
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (SONARUSER.LIVE_MEASURES_COMPONENT) violated

        at oracle.jdbc.driver.OraclePreparedStatement.executeLargeBatch(OraclePreparedStatement.java:10032)
        at oracle.jdbc.driver.T4CPreparedStatement.executeLargeBatch(T4CPreparedStatement.java:1364)
        at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9839)
        at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:234)
        at org.apache.commons.dbcp2.DelegatingStatement.executeBatch(DelegatingStatement.java:223)
        at org.apache.commons.dbcp2.DelegatingStatement.executeBatch(DelegatingStatement.java:223)
        at org.sonar.server.platform.db.migration.step.UpsertImpl.addBatch(UpsertImpl.java:56)
        at org.sonar.server.platform.db.migration.step.MassUpdate.callSingleHandler(MassUpdate.java:119)
        at org.sonar.server.platform.db.migration.step.MassUpdate.lambda$execute$0(MassUpdate.java:92)
        at org.sonar.server.platform.db.migration.step.SelectImpl.scroll(SelectImpl.java:78)
        ... 13 common frames omitted

(Simon Brandhof) #5

Hi Adrian,

Could you please run the following SQL requests to help us understanding the problem?

SELECT p.uuid, pm.metric_id, count(*)
FROM project_measures pm
INNER JOIN projects p on p.uuid = pm.component_uuid 
INNER JOIN snapshots s on s.uuid = pm.analysis_uuid 
WHERE s.islast = 1 and pm.person_id is null
group by p.uuid, pm.metric_id
having count(*)>1

and

SELECT pm.*, s.*
FROM project_measures pm
INNER JOIN snapshots s on s.uuid = pm.analysis_uuid 
WHERE s.islast = 1 and pm.person_id is null and pm.component_uuid = 'AVTNVNBUobjp3nKU_brv'
ORDER BY metric_id, person_id

Thanks

EDIT: just edited the second request to add “s.*” in the SELECT.