1

After following the usual upgrade procedure to upgrade from 5.6.1 to 6.0, the SonarQube server doesn't start:

ActiveRecord::JDBCError: Table 'projects' already exists

CREATE TABLE `projects` (
    `id` int(11) auto_increment PRIMARY KEY, 
    `name` varchar(256), 
    `description` varchar(2000), 
    `enabled` tinyint(1) DEFAULT 1 NOT NULL, 
    `scope` varchar(3), 
    `qualifier` varchar(10), 
    `kee` varchar(400), 
    `root_id` integer, 
    `language` varchar(20), 
    `copy_resource_id` integer, 
    `long_name` varchar(256), 
    `person_id` integer, 
    `created_at` datetime
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin

This error happens when:

  • Starting the 6.0 just after deploying the new distribution and configuring it according to the upgrade procedure
  • It is configured to connect to the existing 5.6.1 database (same location, credentials, etc..) running on MySQL 5.7
  • At that stage, I didn't run any db upgrade

The same error occurs if I start again the sonarqube server

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • 1
    If you didn't trigger the migration by going to the /setup page, SQ doing DDL operations are startup most likely means that it is trying to initialize the schema and create its whole database. My guess would then be that SQ incorrectly detects that the DB is empty, which is does by querying table schema_migrations. Does this table exist? Is it accessible with the user account SQ connects to the DB with? is this table empty? – Seb - SonarSource Team Sep 02 '16 at 12:10
  • Yes, schema_migrations and projects tables exist and can be queried using the same user as SonarQube: D:\MySQL\MySQL Server 5.7\bin>mysql -u sonar -p sonar Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. [...] mysql> select count(*) from schema_migrations; +----------+ | count(*) | +----------+ | 400 | +----------+ mysql> select count(*) from projects; +----------+ | count(*) | +----------+ | 73621 | +----------+ – Jean-Francois Sep 02 '16 at 13:13
  • At that point I can only encourage you to double check all configuration and assume nothing. Everything indicates SQ does not read any row from table schema_migrations (either it is empty or it seems non existent) and assumes from there the DB is empty. – Seb - SonarSource Team Sep 02 '16 at 14:21
  • Well, after simply restarting MySQL, that issue isn't reproduced... I have no explanation (no error was reported on MySQL side). We can close this report – Jean-Francois Sep 06 '16 at 20:11

0 Answers0