SonarQube upgrade 4.2 -> 4.3.2 UpdateMeasuresDebtT

2019-08-24 03:03发布

问题:

When upgrading SonarQube 4.2 to 4.3.2 on Windows 7 Enterprise / SQL Server 2012 / Java 7 Update 51 64bit JDK

The setup screen stated:

SonarQube Database is currenly upgrading.

Started about 22 hours ago (14 Jul 2014 11:45)

The sonar.log file is as follows:

--> Wrapper Started as Console

Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2014.07.14 11:42:31 INFO  [o.s.a.Connectors]  HTTP connector is enabled on port 9000
2014.07.14 11:42:32 INFO  [o.a.c.h.Http11Protocol]  Initializing ProtocolHandler ["http-bio-0.0.0.0-9000"]
2014.07.14 11:42:32 INFO  [o.a.c.c.StandardService]  Starting service Tomcat
2014.07.14 11:42:32 INFO  [o.a.c.c.StandardEngine]  Starting Servlet Engine: Apache Tomcat/7.0.42
2014.07.14 11:42:32 INFO  [o.a.c.s.ContextConfig]  No global web.xml found
2014.07.14 11:42:33 INFO  [o.s.s.p.ServerImpl]  SonarQube Server / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:33 INFO  [o.s.c.p.Database]  Create JDBC datasource for jdbc:jtds:sqlserver://localhost/sonardb;SelectMethod=Cursor
2014.07.14 11:42:34 INFO  [o.s.s.p.DatabaseServerCompatibility]  Database must be upgraded. Please browse /setup
2014.07.14 11:42:34 INFO  [o.s.s.p.DefaultServerFileSystem]  SonarQube home: C:\sonarqube-4.3.2
2014.07.14 11:42:34 INFO  [o.s.s.p.DefaultServerFileSystem]  Deploy dir: C:\sonarqube-4.3.2\web\deploy
2014.07.14 11:42:34 INFO  [org.sonar.INFO]  Install plugins...
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Findbugs / 2.3 / a231b7d2488255a3494a8704d8ebd3e92af7d0bf
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Timeline / 1.4 / 5dbb36d5db80475315f3f39ac3ec506ef92a9d6a
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Build Stability / 1.2 / 2b32f73fbe180e8b5b6f56271018e3b0cd2c477d
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Clirr / 1.1
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin English Pack / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin SCM Activity / 1.7.1 / 233895448799dc2ab0274aa518a77cc1b93fed7f
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Duplications / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Doxygen / 0.1 / 6014
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin PMD / 2.2 / a5da0c1cde1bd7be862a09dbb743fd9367c849d6
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Squid for Java / 2.3 / a231b7d2488255a3494a8704d8ebd3e92af7d0bf
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Email notifications / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Motion Chart / 1.7 / e9c4a5c95c75564b3c3b5a887b63ef50fc59a156
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin JavaScript / 1.6 / 854b85c280793d4f983742a37b33b0449e2a65d4
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Security Rules / 0.3.2
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin XML / 1.2 / 8a0e3c61b4bf3568125302a7ac87d677e8566c1f
2014.07.14 11:42:34 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin JaCoCo / 2.3 / a231b7d2488255a3494a8704d8ebd3e92af7d0bf
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Widget Lab / 1.4.1 / f4e93e520bbecc47db57d42010c8fd267bb6e675
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Scm Stats / 0.3.1 / fd4f129d8cc73da085723c50b94936d74b1dc975
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Maven Batch Plugin / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Surefire / 2.3 / a231b7d2488255a3494a8704d8ebd3e92af7d0bf
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Tab Metrics / 1.4 / fa240469a783a0fe5b76c752ed014add30a346df
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Checkstyle / 2.1 / 219b216223e3e2477d1588064f25fca77be922a9
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Java / 2.3 / a231b7d2488255a3494a8704d8ebd3e92af7d0bf
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Core / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Database Cleaner / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Cobertura / 1.6.2 / 97fa42dd2ec9396debeeee6622eaa1df59e71f12
2014.07.14 11:42:35 INFO  [o.s.s.p.ServerPluginJarsInstaller]  Deploy plugin Design / 4.3.2 / a82ddddad45acebdce81bdf70767a4ee11147392
2014.07.14 11:42:35 INFO  [org.sonar.INFO]  Install plugins done: 405 ms
2014.07.14 11:42:35 INFO  [o.s.s.p.RailsAppsDeployer]  Deploy Ruby on Rails applications
2014.07.14 11:42:35 INFO  [o.s.s.p.RailsAppsDeployer]  Deploy app: motionchart
2014.07.14 11:42:35 INFO  [jruby.rack]  jruby 1.7.9 (ruby-1.8.7p370) 2013-12-06 87b108a on Java HotSpot(TM) 64-Bit Server VM 1.7.0_51-b13 [Windows 7-amd64]
2014.07.14 11:42:35 INFO  [jruby.rack]  using a shared (threadsafe!) runtime
2014.07.14 11:42:46 INFO  [jruby.rack]  keeping custom (config.logger) Rails logger instance
Database must be upgraded. Please browse /setup
2014.07.14 11:42:46 INFO  [o.a.c.h.Http11Protocol]  Starting ProtocolHandler ["http-bio-0.0.0.0-9000"]
2014.07.14 11:42:46 INFO  Web server is started
2014.07.14 11:45:23 INFO  [DbMigration]  ==  CreateQualityGates: migrating =============================================
2014.07.14 11:45:23 INFO  [DbMigration]  -- create_table(:quality_gates, {})
2014.07.14 11:45:23 INFO  [DbMigration]     -> 0.0090s
2014.07.14 11:45:23 INFO  [DbMigration]     -> 0 rows
2014.07.14 11:45:23 INFO  [DbMigration]  -- add_index("quality_gates", ["name"], {:unique=>true, :name=>"uniq_quality_gates"})
2014.07.14 11:45:23 INFO  [DbMigration]     -> 0.0450s
2014.07.14 11:45:23 INFO  [DbMigration]     -> 0 rows
2014.07.14 11:45:23 INFO  [DbMigration]  ==  CreateQualityGates: migrated (0.0560s) ====================================
2014.07.14 11:45:23 INFO  [DbMigration]  
2014.07.14 11:45:23 INFO  [DbMigration]  ==  CreateQualityGateConditions: migrating ====================================
2014.07.14 11:45:23 INFO  [DbMigration]  -- create_table(:quality_gate_conditions, {})
2014.07.14 11:45:23 INFO  [DbMigration]     -> 0.0050s
2014.07.14 11:45:23 INFO  [DbMigration]     -> 0 rows
2014.07.14 11:45:23 INFO  [DbMigration]  ==  CreateQualityGateConditions: migrated (0.0050s) ===========================
2014.07.14 11:45:23 INFO  [DbMigration]  
2014.07.14 11:45:23 INFO  [DbMigration]  ==  ConvertAlertsToQualityGates: migrating ====================================
2014.07.14 11:45:23 INFO  [DbMigration]  ==  ConvertAlertsToQualityGates: migrated (0.0730s) ===========================
2014.07.14 11:45:23 INFO  [DbMigration]  
2014.07.14 11:45:23 INFO  [DbMigration]  ==  UpdateIssueDebtToMinutes: migrating =======================================
2014.07.14 11:45:34 INFO  [o.s.s.d.m.MassUpdater]  447217 rows have been updated
2014.07.14 11:45:34 INFO  [DbMigration]  ==  UpdateIssueDebtToMinutes: migrated (10.5750s) =============================
2014.07.14 11:45:34 INFO  [DbMigration]  
2014.07.14 11:45:34 INFO  [DbMigration]  ==  UpdateIssueChangelogDebtToMinutes: migrating ==============================
2014.07.14 11:45:35 INFO  [o.s.s.d.m.MassUpdater]  39 rows have been updated
2014.07.14 11:45:35 INFO  [DbMigration]  ==  UpdateIssueChangelogDebtToMinutes: migrated (1.0090s) =====================
2014.07.14 11:45:35 INFO  [DbMigration]  
2014.07.14 11:45:35 INFO  [DbMigration]  ==  UpdateMeasuresDebtToMinutes: migrating ====================================

Running a SQL Server Trace the only database activity that appears is a 'SELECT 1' every few seconds

Reviewed SQL Activity Monitor and noted the following SQL Statements where blocking:

SQL Process: 56 blocked by 56

SELECT pm.id, pm.value , pm.variation_value_1 , pm.variation_value_2, pm.variation_value_3 , pm.variation_value_4 , pm.variation_value_5  FROM project_measures pm INNER JOIN metrics m on m.id=pm.metric_id  WHERE (m.name='sqale_index' or m.name='new_technical_debt'  or m.name='sqale_effort_to_grade_a' or m.name='sqale_effort_to_grade_b' or m.name='sqale_effort_to_grade_c' or m.name='sqale_effort_to_grade_d'  or m.name='blocker_remediation_cost' or m.name='critical_remediation_cost' or m.name='major_remediation_cost' or m.name='minor_remediation_cost'  or m.name='info_remediation_cost' )

SQL Process: 58 blocked by 56

(@P0 float,@P1 float,@P2 float,@P3 float,@P4 float,@P5 float,@P6 bigint)UPDATE project_measures SET value= @P0 ,variation_value_1= @P1 ,variation_value_2= @P2 ,variation_value_3= @P3 ,variation_value_4= @P4 ,variation_value_5= @P5  WHERE id= @P6 

After waiting for 22+ Hours killed SQL process 58 and noted the following stacktace in the sonar.log:

2014.07.15 10:13:50 INFO  [o.s.s.d.m.MassUpdater]  8000 rows have been updated
2014.07.15 10:13:50 ERROR [o.s.s.d.m.DatabaseMigrator]  Fail to execute database migration: org.sonar.server.db.migrations.v43.TechnicalDebtMeasuresMigration
org.sonar.api.utils.MessageException: Fail to migrate data, error is : The server returned an unspecified error.

Can anyone tell me if the upgrade had in fact hung or is it just slow, has anyone else encountered this and if so how was it resolved.

I have reviewed a similar post for this issue when upgrading from 4.2 to 4.3 but I am upgrading to 4.3.2, in which I thought this issue was resolved.

回答1:

I have resolved this issue myself by applying the following database indexes:

CREATE NONCLUSTERED INDEX [exelidx_metric_id]
ON [dbo].[project_measures] ([metric_id])
INCLUDE ([id],[value],[variation_value_1],[variation_value_2],[variation_value_3],[variation_value_4],[variation_value_5])
GO

CREATE NONCLUSTERED INDEX [exelidx_characteristic_id]
ON [dbo].[project_measures] ([characteristic_id])
INCLUDE ([id])
GO

Upgrade completed sucessfully in 8 minutes.