Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to 1.5.0 fails during database migration #4694

Closed
2 of 7 tasks
fgtham opened this issue Aug 13, 2018 · 2 comments
Closed
2 of 7 tasks

Upgrade to 1.5.0 fails during database migration #4694

fgtham opened this issue Aug 13, 2018 · 2 comments
Labels
issue/duplicate The issue has already been reported.

Comments

@fgtham
Copy link

fgtham commented Aug 13, 2018

  • Gitea version (or commit ref): 1.4.3
  • Git version: 2.11.0
  • Operating system: Raspbian 9.4 (stretch)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I'm trying to upgrade from 1.4.3 to 1.5.0 following the docs. Starting gitea 1.5.0 triggers DB migration, which then fails to complete and gitea crashes instead. From gitea.log:

2018/08/13 16:06:29 [I] Log Mode: File(Info)
2018/08/13 16:06:29 [I] XORM Log Mode: File(Info)
2018/08/13 16:06:29 [I] Cache Service Enabled
2018/08/13 16:06:29 [I] Session Service Enabled
2018/08/13 16:06:29 [I] Migration: Reformat and remove incorrect topics
2018/08/13 16:06:29 [I] This migration could take up to minutes, please be patient.
2018/08/13 16:06:30 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Sync2: Error 1071: Specified key was too long; max key length is 767 bytes

The problem might be the MySQL DB character set:

# mysql -e 'show create database gitea'
+----------+-------------------------------------------------------------------+
| Database | Create Database                                                   |
+----------+-------------------------------------------------------------------+
| gitea    | CREATE DATABASE `gitea` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+-------------------------------------------------------------------+

According to this stackoverflow answer, the problem lies within the fact that utf8mb4 uses up to 4 bytes per char. Creating a unique index on a varchar(255) field then exceeds the max key length of 767 bytes, as 4*255 = 1020.

The MySQL docs state that:

Prefix limits are measured in bytes. However, prefix lengths for index specifications in CREATE TABLE, ALTER TABLE, and CREATE INDEX statements are interpreted as number of characters for nonbinary string types (CHAR, VARCHAR, TEXT) and number of bytes for binary string types (BINARY, VARBINARY, BLOB). Take this into account when specifying a prefix length for a nonbinary string column that uses a multibyte character set.

Is there any way to keep using gitea with a utfmb4 character set, or is this simply not supported (yet)?

@SagePtr
Copy link
Contributor

SagePtr commented Aug 13, 2018

Is there any way to keep using gitea with a utfmb4 character set, or is this simply not supported (yet)?

Setting innodb_large_prefix option in my.cnf for example. Or update MySQL to 5.7.7 or more recent version where this option is on by default.

@Pofilo
Copy link
Contributor

Pofilo commented Aug 13, 2018

You should take a look of other issues before !

Duplicate of #4663 which is already a duplicate ;)

@lafriks lafriks closed this as completed Aug 13, 2018
@lafriks lafriks added the issue/duplicate The issue has already been reported. label Aug 13, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/duplicate The issue has already been reported.
Projects
None yet
Development

No branches or pull requests

4 participants