1
votes

I'm trying to updgrade Sonarqube from 4.5 to 4.5.1 on Ubuntu 14.04 64 bits. The package manager serves the new version and it installed apparently without any problem. However, when I try to access the web UI it takes me to the page where it says I need to upgrade the database. So I go to the my_sonar_server/setup page and click upgrade. After few seconds, the following message appears

Exclamation Impossible to upgrade database

Migration failed: An error has occurred, all later migrations canceled: ActiveRecord::ConnectionNotEstablished: no connection available: alter table snapshot_sources modify data longtext . Please check logs.

The sonar.log has the following exception

2014.11.10 10:04:38 INFO web[DbMigration] MysqlMediumtextToLongtext: migrating

2014.11.10 10:04:42 ERROR web[o.s.s.ui.JRubyFacade] Fail to upgrade database An error has occurred, all later migrations canceled:

ActiveRecord::ConnectionNotEstablished: no connection available: alter table snapshot_sources modify data longtext /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in log' /opt/sonar/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:183:in execute' /opt/sonar/web/WEB-INF/db/migrate/600_mysql_mediumtext_to_longtext.rb:42:in apply' /opt/sonar/web/WEB-INF/db/migrate/600_mysql_mediumtext_to_longtext.rb:30:in up' org/jruby/RubyKernel.java:2223:in send' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in migrate' jar:file:/opt/sonar/lib/server/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/benchmark.rb:293:in measure' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in migrate' org/jruby/RubyKernel.java:2227:in send' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:365:in migrate' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:491:in migrate' org/jruby/RubyProc.java:290:incall' org/jruby/RubyProc.java:224:in call' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:567:in ddl_transaction' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:490:in migrate' org/jruby/RubyArray.java:1613:ineach' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:477:in migrate' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401:in up' /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383:in migrate' /opt/sonar/web/WEB-INF/lib/database_version.rb:62:inupgrade_and_start' /opt/sonar/web/WEB-INF/app/models/database_migration_manager.rb:109:in start_migration' org/jruby/RubyProc.java:290:incall' org/jruby/RubyProc.java:228:in `call'

Any help here would be much appreciated!

Thanks

2

2 Answers

3
votes

The problem was that one of tables (snapshot_sources) got corrupted at some point, presumably when we cloned our production server to have a test server.

When I tried to access a particular row on that particular table either through phpmyadmin or the command line, the database connection was lost (mysqld process was restarting itself). I investigated the root of the problem (by digging /var/log/mysql/error.log) along with our IT team, and reached the aforementioned conclusion.

So, the migration of the database was being interrupted because of this, due to the fact that the migration was trying to alter snapshot_sources table to convert the data field from mediumtext to longtext

The way I fixed it was:

  1. Export the production DB (with truncate sentences to empty the tables before importing)
  2. Backup the corrupted DB for further investigation if required
  3. Import the production DB onto the test server
  4. Upgrade SQ from 4.5 to 4.5.1

Hope this helps someone else or at least it is a sort of heads up for Sonar team.

-1
votes

The log is explicit enough: ConnectionNotEstablished. This means that you haven't configured your SonarQube instance correctly to access the database...