Markus Kreusch
Markus Kreusch

Reputation: 2121

Schema setup fails using Sonar and MySQL 5.6 on windows

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 [email protected]:9000

Upvotes: 3

Views: 1514

Answers (1)

Simon Brandhof
Simon Brandhof

Reputation: 5136

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).

Upvotes: 2

Related Questions