Installation broken with mysql < 5.7.7
Summary
The installation from source of Gitlab CE 8.15.2 fails with a mysql error (Mysql2::Error: Specified key was too long; max key length is 767 bytes
) during database setup.
Steps to reproduce
Install Gitlab CE 8.15.2 from source according to the instructions in https://gitlab.com/gitlab-org/gitlab-ce/blob/v8.15.2/doc/install/installation.md . I've used Debian Wheezy with mysql 5.5.53. The installation fails during the sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
command.
Expected behavior
The database setup should work.
Actual behavior
Creating several database indexes fails.
Relevant logs and/or screenshots
-- add_index("chat_names", ["service_id", "team_id", "chat_id"], {:name=>"index_chat_names_on_service_id_and_team_id_and_chat_id", :unique=>true, :using=>:btree})
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `index_chat_names_on_service_id_and_team_id_and_chat_id` USING btree ON `chat_names` (`service_id`, `team_id`, `chat_id`)
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `query'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `block in execute'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `execute'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
/home/git/gitlab/config/initializers/connection_fix.rb:20:in `execute'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:541:in `add_index'
/home/git/gitlab/config/initializers/mysql_ignore_postgresql_options.rb:23:in `add_index'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:665:in `block in method_missing'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `block in say_with_time'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `say_with_time'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:654:in `method_missing'
/home/git/gitlab/db/schema.rb:167:in `block in <top (required)>'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/schema.rb:41:in `instance_eval'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/schema.rb:41:in `define'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/schema.rb:61:in `define'
/home/git/gitlab/db/schema.rb:14:in `<top (required)>'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `block in load'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:219:in `load_schema_for'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:236:in `block in load_schema_current'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:235:in `load_schema_current'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:247:in `block (3 levels) in <top (required)>'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:251:in `block (3 levels) in <top (required)>'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
/home/git/gitlab/lib/tasks/gitlab/setup.rake:17:in `setup_db'
/home/git/gitlab/lib/tasks/gitlab/setup.rake:4:in `block (2 levels) in <top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:in `<main>'
Output of checks
Results of GitLab application Check
Not useful as the installation is not yet completed.
Results of GitLab environment info
System information
System: Debian 7.11
Current User: git
Using RVM: no
Ruby Version: 2.3.3p222
Gem Version: 2.5.2
Bundler Version:1.13.7
Rake Version: 10.5.0
Sidekiq Version:4.2.7
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'gitlabhq_production.namespaces' doesn't exist: SHOW FULL FIELDS FROM `namespaces`
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `query'
...
Possible fixes
From what I can tell this is caused by !7420 (merged) . The merge request changes the mysql encoding from utf8 to utf8mb4. The maximum bytes per column supported by InnoDB are 767 bytes (see http://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html). The utf8 encoding uses 3 bytes per character, utf8mb4 uses 4. With string columns having a default column width of 255 characters, it is therefore not possible to use those in an index with the utf8mb4 encoding. This limit is raised to 3072 bytes with the innodb_large_prefix option, which, however, is only enabled by default for mysql >= 5.7.7.