在DropUnusedMeasuresColumns中,Sonarqube 5.6到6.0数据库迁移失败

时间:2016-08-12 15:23:38

标签: sonarqube sonarqube-ops

从Sonarqube 5.6版升级到6.0时,升级过程失败,并显示以下错误:

2016.08.12 14:56:35 ERROR web[o.s.s.d.m.DatabaseMigrator] Fail to execute database migration: org.sonar.db.version.v60.DropUnusedMeasuresColumns
java.lang.IllegalStateException: Fail to execute ALTER TABLE project_measures DROP COLUMN rules_category_id, DROP COLUMN tendency, DROP COLUMN measure_date, DROP COLUMN url, DROP COLUMN rule_priority, DROP COLUMN characteristic_id, DROP COLUMN rule_id

当前表看起来像这样,并且没有任何应该删除的列。

CREATE TABLE `project_measures` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `value` decimal(38,20) DEFAULT NULL,
  `metric_id` int(11) NOT NULL,
  `snapshot_id` int(11) DEFAULT NULL,
  `text_value` varchar(4000) COLLATE utf8_bin DEFAULT NULL,
  `project_id` int(11) DEFAULT NULL,
  `alert_status` varchar(5) COLLATE utf8_bin DEFAULT NULL,
  `alert_text` varchar(4000) COLLATE utf8_bin DEFAULT NULL,
  `description` varchar(4000) COLLATE utf8_bin DEFAULT NULL,
  `variation_value_1` decimal(38,20) DEFAULT NULL,
  `variation_value_2` decimal(38,20) DEFAULT NULL,
  `variation_value_3` decimal(38,20) DEFAULT NULL,
  `variation_value_4` decimal(38,20) DEFAULT NULL,
  `variation_value_5` decimal(38,20) DEFAULT NULL,
  `person_id` int(11) DEFAULT NULL,
  `measure_data` longblob,
  PRIMARY KEY (`id`),
  KEY `measures_sid_metric` (`snapshot_id`,`metric_id`),
  KEY `measures_person` (`person_id`)
) ENGINE=InnoDB AUTO_INCREMENT=81903974 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

该表有350万条记录,随着时间的推移,我们已经升级了5.4到5.5到5.6之间没有问题。

有谁知道如何手动修复此问题,以便我们继续升级过程?

更新

以下是进行第二次尝试时的迁移日志。 DropUnusedMeasuresColumns似乎挂了。

2016.08.16 08:29:12 INFO  web[o.s.s.d.m.PlatformDatabaseMigration] Starting DB Migration
2016.08.16 08:29:14 INFO  web[DbMigration] ==  UpdateUsersExternalIdentityWhenEmpty: migrating ===========================
2016.08.16 08:29:14 INFO  web[o.s.d.v.MassUpdate] 0 users processed (0 items/sec)
2016.08.16 08:29:14 INFO  web[DbMigration] ==  UpdateUsersExternalIdentityWhenEmpty: migrated (0.0950s) ==================
2016.08.16 08:29:14 INFO  web[DbMigration] 
2016.08.16 08:29:14 INFO  web[DbMigration] ==  CreatePermTemplatesCharacteristics: migrating =============================
2016.08.16 08:29:14 INFO  web[DbMigration] -- create_table("perm_tpl_characteristics", {})
2016.08.16 08:29:15 INFO  web[DbMigration]    -> 0.5600s
2016.08.16 08:29:15 INFO  web[DbMigration]    -> 0 rows
2016.08.16 08:29:15 INFO  web[DbMigration] -- index_exists?("perm_tpl_characteristics", ["template_id", "permission_key"], {:name=>"uniq_perm_tpl_charac"})
2016.08.16 08:29:15 INFO  web[DbMigration]    -> 0.0650s
2016.08.16 08:29:15 INFO  web[DbMigration] -- add_index("perm_tpl_characteristics", ["template_id", "permission_key"], {:name=>"uniq_perm_tpl_charac", :unique
=>true})
2016.08.16 08:29:15 INFO  web[DbMigration]    -> 0.6200s
2016.08.16 08:29:15 INFO  web[DbMigration]    -> 0 rows
2016.08.16 08:29:15 INFO  web[DbMigration] ==  CreatePermTemplatesCharacteristics: migrated (1.2580s) ====================
2016.08.16 08:29:15 INFO  web[DbMigration] 
2016.08.16 08:29:15 INFO  web[DbMigration] ==  AddColumnsWithUuidsToResourceIndex: migrating =============================
2016.08.16 08:29:54 INFO  web[DbMigration] ==  AddColumnsWithUuidsToResourceIndex: migrated (38.6700s) ===================
2016.08.16 08:29:54 INFO  web[DbMigration] 
2016.08.16 08:29:54 INFO  web[DbMigration] ==  PopulateUuidColumnsOfResourceIndex: migrating =============================
2016.08.16 08:30:42 INFO  ce[o.s.c.a.WebServerWatcherImpl] Still waiting for WebServer...
2016.08.16 08:31:00 INFO  web[o.s.d.v.MassUpdate] 149749 resource index entries processed (2495 items/sec)
2016.08.16 08:32:00 INFO  web[o.s.d.v.MassUpdate] 310999 resource index entries processed (2687 items/sec)
2016.08.16 08:32:19 INFO  web[o.s.d.v.MassUpdate] 362861 resource index entries processed (864 items/sec)
2016.08.16 08:32:19 INFO  web[DbMigration] ==  PopulateUuidColumnsOfResourceIndex: migrated (145.4370s) ==================
2016.08.16 08:32:19 INFO  web[DbMigration] 
2016.08.16 08:32:20 INFO  web[DbMigration] ==  CleanOrphanRowsInResourceIndex: migrating =================================
2016.08.16 08:32:20 INFO  web[o.s.d.v.MassUpdate] 0 resource index entries processed (0 items/sec)
2016.08.16 08:32:20 INFO  web[DbMigration] ==  CleanOrphanRowsInResourceIndex: migrated (0.1980s) ========================
2016.08.16 08:32:20 INFO  web[DbMigration] 
2016.08.16 08:32:20 INFO  web[DbMigration] ==  MakeUuidColumnsNotNullOnResourceIndex: migrating ==========================
2016.08.16 08:33:09 INFO  web[DbMigration] -- index_exists?(:resource_index, :component_uuid, {:name=>"resource_index_component"})
2016.08.16 08:33:09 INFO  web[DbMigration]    -> 0.0090s
2016.08.16 08:33:09 INFO  web[DbMigration] -- add_index(:resource_index, :component_uuid, {:name=>"resource_index_component"})
2016.08.16 08:33:18 INFO  web[DbMigration]    -> 9.4810s
2016.08.16 08:33:18 INFO  web[DbMigration]    -> 0 rows
2016.08.16 08:33:18 INFO  web[DbMigration] ==  MakeUuidColumnsNotNullOnResourceIndex: migrated (58.3240s) ================
2016.08.16 08:33:18 INFO  web[DbMigration] 
2016.08.16 08:33:18 INFO  web[DbMigration] ==  DropResourceIndexRidFromResourceIndex: migrating ==========================
2016.08.16 08:33:18 INFO  web[DbMigration] -- remove_index(:resource_index, {:name=>"resource_index_rid"})
2016.08.16 08:33:19 INFO  web[DbMigration]    -> 0.4860s
2016.08.16 08:33:19 INFO  web[DbMigration]    -> 0 rows
2016.08.16 08:33:19 INFO  web[DbMigration] ==  DropResourceIndexRidFromResourceIndex: migrated (0.4890s) =================
2016.08.16 08:33:19 INFO  web[DbMigration] 
2016.08.16 08:33:19 INFO  web[DbMigration] ==  DropIdColumnsFromResourceIndex: migrating =================================
2016.08.16 08:34:08 INFO  web[DbMigration] ==  DropIdColumnsFromResourceIndex: migrated (48.7900s) =======================
2016.08.16 08:34:08 INFO  web[DbMigration] 
2016.08.16 08:34:08 INFO  web[DbMigration] ==  DropUnusedMeasuresColumns: migrating ======================================
2016.08.16 08:34:57 INFO  ce[o.s.c.a.WebServerWatcherImpl] Still waiting for WebServer...
2016.08.16 08:46:31 INFO  ce[o.s.c.a.WebServerWatcherImpl] Still waiting for WebServer...

1 个答案:

答案 0 :(得分:0)

问题是磁盘空间似乎mySql创建的临时表太大而磁盘无法处理。 释放一些空间,升级可以正常运行