Skip to content
Snippets Groups Projects
Commit 242512ba authored by Christian Pointner's avatar Christian Pointner
Browse files

Improve explanation of MariaDB (Ubuntu 18.04 is also affected)

fixes #1
parent 63f93003
No related branches found
No related tags found
No related merge requests found
......@@ -22,16 +22,16 @@ And then run the `tank` binary:
$ $GOPATH/bin/tank --config config.yaml run --listen localhost:8040
```
### Problem with MariaDB on Debian 9 (stretch)
### Problem with some versions of MariaDB
If you start `tank` for the first time you may get the following error message:
If you start `tank` for the first time using MariaDB you may get the following error message:
```
running database migrations failed: Error 1071: Specified key was too long; max key length is 767 bytes
```
This most likely means you are using a MariaDB server running on Debian 9 (stretch). Please read
[contrib/mariadb-stretch-err1071.md](/contrib/mariadb-stretch-err1071.md) for help.
This most likely means you are using an older version of MariaDB with the default character-set set to
`utf8mb4`. Please read [contrib/mariadb-stretch-err1071.md](/contrib/mariadb-stretch-err1071.md) for help.
If you encouter this problem on any other platform please let us know!
......
......@@ -2,14 +2,15 @@
## Background
`tank` stores shows using it's name as primary key. Since this is a string it
by default is mapped to a `VARCHAR(255)` inside the database.
Starting with Debian 9 (stretch) MariaDB is installed instead of mySQL. Debian also
switched to `utf8mb4` as the default character set in an attempt to support Emoji's
stored as UTF-8 characters in the database.
This means that a `VARCHAR(255)` is now 1021 bytes long which exceeds the maximum
length (767 bytes) for primary key indices when `innodb` is used (also the default since quite
some time).
`tank` stores shows using it's name as primary key. Since this is a string it by default is
mapped to a `VARCHAR(255)` at the database level.
Some Linux distributions, i.e. Debian 9 (stretch) or Ubuntu 18.04 (bionic) have switched to
the mySQL fork MariaDB. At least Debian und Ubuntu also switched to `utf8mb4` as
the default character-set. This is an attempt to support Emoji's stored as UTF-8 characters in
the database for applications like Wordpress.
When using `utf8mb4` a `VARCHAR(255)` field can be up to 1021 bytes long. This exceeds the
maximum length (767 bytes) for primary key indices on older version of the `innodb` file and row
formats.
## Possible Workarounds
......@@ -26,7 +27,7 @@ create database tank CHARACTER SET utf8 COLLATE utf8_general_ci;
* Debian has [backported](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=886756) some
changes to the MariaDB version in Debian Stretch. Because of this it is possible to switch
to the new innodb layout which is the default for newer version of MariaDB as well as mySQL.
to the new innodb file and row format.
You can do this by adding the following to the `[mysqld]` section of
`/etc/mysql/mariadb.conf.d/50-server.cnf`:
```ini
......@@ -35,14 +36,19 @@ innodb_file_per_table = On
innodb_large_prefix = On
innodb_default_row_format = dynamic
```
As far as i can see Ubuntu did not add this patch to it's packages but starting with 10.2
MariaDB uses the new format by default. This means you can work around the issue by using
the packages provided by the [MariaDB Foundation](https://downloads.mariadb.org/mariadb/repositories/).
* Consider switching to another DBMS:
* `tank` also works with postgres
* you may use the mySQL Community Packages from [Oracle](https://dev.mysql.com/doc/refman/5.7/en/linux-installation-debian.html)
* [Percona Server](https://www.percona.com/software/mysql-database/percona-server) is drop-in replacement for mySQL
* [Percona Server](https://www.percona.com/software/mysql-database/percona-server) is a drop-in
replacement for mySQL
* If for some reason none of the above is applicable as a last resort you can apply the patch below.
This limits the length for show names to 191 characters which is just short enough to not exceed the limit.
* If for some reason none of the above is applicable, as a last resort, you can apply the
patch below. This limits the length for show names to 191 characters which is just short
enough to not exceed the limit.
```patch
diff --git a/store/types.go b/store/types.go
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment