3

I have installed Sonar 3.4.1 and Mysql 5.6.10 on a Windows Machine.

I have created a mysql schema "sonar" and granted all permissions on it to a user "sonar". I have configured sonar to use this user. I did this following the instructions on the codehaus sonar page.

When starting sonar it starts creating tables in the schema. At some point an error occurs stating that the "Specified key was too long; max key length is 767 bytes" (full error message at the end).

According to this question the index length is limited in mysql. Because this is documented I expect Sonar to not create indexes longer than the limit. Obviously it tries to do so.

Did I miss some important configuration or are the two versions of sonar and mysql incompatbile? What can I do to get it working with these versions?

Full error message:

INFO   | jvm 1    | 2013/02/11 11:28:25 | 
INFO   | jvm 1    | 2013/02/11 11:28:25 | ==  CreateProperties: migrating ===============================================
INFO   | jvm 1    | 2013/02/11 11:28:25 | -- create_table("properties")
INFO   | jvm 1    | 2013/02/11 11:28:25 |    -> 0.0320s
INFO   | jvm 1    | 2013/02/11 11:28:25 |    -> 0 rows
INFO   | jvm 1    | 2013/02/11 11:28:25 | -- add_index(:properties, :prop_key, {:name=>"properties_key"})
2013.02.11 11:28:25 ERROR jruby.rack  unable to create shared application instance
org.jruby.rack.RackInitializationException: An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Specified key was too long; max key length is 767 bytes: CREATE  INDEX `properties_key` ON `properties` (`prop_key`)
    from D:/Programs/sonar-3.4.1/war/sonar-server/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:183:in `execute'
[stacktrace omitted]
org.jruby.exceptions.RaiseException: (StandardError) An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Specified key was too long; max key length is 767 bytes: CREATE  INDEX `properties_key` ON `properties` (`prop_key`)
2013.02.11 11:28:25 ERROR jruby.rack  Error: application initialization failed
org.jruby.rack.RackInitializationException: An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Specified key was too long; max key length is 767 bytes: CREATE  INDEX `properties_key` ON `properties` (`prop_key`)
    from D:/Programs/sonar-3.4.1/war/sonar-server/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:183:in `execute'
[stacktrace omitted]
org.jruby.exceptions.RaiseException: (StandardError) An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Specified key was too long; max key length is 767 bytes: CREATE  INDEX `properties_key` ON `properties` (`prop_key`)
INFO   | jvm 1    | 2013/02/11 11:28:25 | 2013-02-11 11:28:25.421:INFO::Started SelectChannelConnector@0.0.0.0:9000
Community
  • 1
  • 1
Markus Kreusch
  • 2,071
  • 3
  • 19
  • 33
  • Tested it with MySQL 5.5.30 and it worked. According to SONAR docs any MySQL 5.x is supported. I have created a [JIRA Issue](http://jira.codehaus.org/browse/SONAR-4137) and will keep this question updated. – Markus Kreusch Feb 11 '13 at 14:15

1 Answers1

2

You're right, some indexes are created with a length greater than the max limit. The issue is that MySQL 5.6 does not silently truncate indexes anymore. This behavior does not seem to be expected (see http://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html and the bug http://bugs.mysql.com/bug.php?id=68453).

All that to say that Sonar 3.5 fixes this issue by creating indexes with the correct length (see http://jira.codehaus.org/browse/SONAR-4137).

Simon Brandhof
  • 5,137
  • 1
  • 21
  • 28
  • Interesting, that the mysql bug got closed as "Not a Bug" eventhough the documentation mentions explicitly, that non unique indexes are truncated. If you add to your answer, that sonar 3.4.1 and mysql 5.6 are incompatible and will not run together i can accept your answer. – Markus Kreusch Mar 20 '13 at 16:55