Sonarqube Primary Key violation

Template for a good bug report, formatted with Markdown:

  • versions used : Sonarqube 7.5 , 7.2.1
    Sonarqube 7.2.1 <–> p_2
    Sonarqube 7.5 <–> d_2 …<-- ← Error happens here when booting up Sonarqube 7.5, with data restored from p_2

  • steps to reproduce

Sonarqube 7.2.1 <–> p_2 Schema <–Source Schema
Sonarqube 7.5 <–> d_2 Schema ← Destination Schema.

We basically tried to restore schema and data from p_2(SOURCE schema) to d_2(DESTINATION schema) .
We wiped the destination schema clean (remove all objects with its data) before the restore.

We got the unique (primary) key error “SONARQUBE.PK_GROUP_ROLES violated” and it is failing when trying to insert row with (foreign or primary) key “1”.

Should the Source Sonarqube App(that uses Source schema) and/or Destination Sonarqube (that uses destination schema) be shutdown , for a dB Backup and restore ? (or)
this is indicative of something messed up(sequence or some forgotten dbObject) during the backup and restore…

  • potential workaround

NONE. We are stuck…in doing a POC, if S.Q 7.2 is upgradable to Enterprise 7.5

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

Sonarqube Support,

We basically tried to restore schema and data from p_2(SOURCE schema) to d_2(DESTINATION schema) .
We wiped the destination schema clean (remove all objects with its data) before the restore.
We got the unique (primary) key error “SONARQUBE.PK_GROUP_ROLES violated” and it is failing when trying to insert row with (foreign or primary) key “1”.

Should the Source Sonarqube App(that uses Source schema) and/or Destination Sonarqube (that uses destination schema) be shutdown , for a dB Backup and restore ? (or) this indicative of something messed up(sequence or some forgotten dbObject) during the backup and restore…

Redirecting to Google Groups → similar.

  • error observed (wrap logs/code around triple quote ``` for proper formatting)
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #2203 'Add 'securityhotspotadmin' permission to all groups already having 'issueadmin'' 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:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Error during processing of row: [group_id=1,resource_id=41431,organization_uuid=AWPgzxfSia_P5Y6mYquD]
        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.v73.PopulateHotspotAdminPermissionOnGroups.execute(PopulateHotspotAdminPermissionOnGroups.java:56)
        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 (SONARQUBE.PK_GROUP_ROLES) violated
 
        at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:12296)
        at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:246)
        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```

Hi,

The root problem could be the Oracle sequences that you forgot to restore when copying table contents.

Regards

Outside of the context of this issue,

Is it recommended for SQ to be shut down during the migration? or NOT necessary ?

Greetings Mahesh,

It is necessary, just as necessary as it is to stick to one question/issue per topic. :slight_smile:

Colin

7 Likes

SOLUTION.

Thanks Colin H Mueller