Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
86481177
Commit
86481177
authored
6 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
added workarounds for sql error 1071
parent
e48e95f2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+5
-5
5 additions, 5 deletions
README.md
contrib/mysql/init.sql
+1
-0
1 addition, 0 deletions
contrib/mysql/init.sql
mariadb-stretch-err1071.md
+74
-1
74 additions, 1 deletion
mariadb-stretch-err1071.md
with
80 additions
and
6 deletions
README.md
+
5
−
5
View file @
86481177
...
...
@@ -13,7 +13,7 @@ $ go get gitlab.servus.at/autoradio/tank/...
Create configuration file see:
https://gitlab.servus.at/autoradio/tank/blob/master/contrib/sample-cfg.yaml
Make sure that the directory pointed to by
``
`store.path`
``
exists and is writeable
Make sure that the directory pointed to by
`store.path`
exists and is writeable
for the user running the daemon
And then run the
`tank`
binary:
...
...
@@ -24,7 +24,7 @@ $ $GOPATH/bin/tank --config config.yaml run --listen localhost:8000
### Problem with MariaDB on Debian 9 (stretch)
If you start
``
`tank`
``
for the first time you may get the following error message:
If you start
`tank`
for the first time you may get the following error message:
```
running database migrations failed: Error 1071: Specified key was too long; max key length is 767 bytes
...
...
@@ -52,8 +52,8 @@ You may run the daemon using the following command:
$
./contrib/run.sh
```
This is using
``
`contrib/sample-cfg.yaml`
``
and depends on a mysql or postgres server
running on localhost. You may use the scripts inside
``
`contrib/`
``
to start docker
This is using
`contrib/sample-cfg.yaml`
and depends on a mysql or postgres server
running on localhost. You may use the scripts inside
`contrib/`
to start docker
containers for this purpose.
### mysql
...
...
@@ -102,5 +102,5 @@ After the daemon has ran the initial migrations you may check out the schema of
$$$
psql < info.sql
```
Once you are done with the database you can stop the server by pressing
``
`CTRL-C`
``
inside the
Once you are done with the database you can stop the server by pressing
`CTRL-C`
inside the
terminal of the server.
This diff is collapsed.
Click to expand it.
contrib/mysql/init.sql
+
1
−
0
View file @
86481177
drop
database
tank
;
create
database
tank
;
-- create database tank CHARACTER SET utf8 COLLATE utf8_general_ci;
grant
all
privileges
on
tank
.
*
to
'tank'
@
'%'
identified
by
'aura'
;
use
tank
;
This diff is collapsed.
Click to expand it.
mariadb-stretch-err1071.md
+
74
−
1
View file @
86481177
# MariaDB `Error 1071: Specified key was too long`
tba...
## Background
`tank`
stores groups 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).
## Possible Workarounds
There are several possible workarounds for the problem:
*
create the database using
`utf8`
(not
`utf8mb4`
):
When creating the database use the following command:
```
mysql
create database tank CHARACTER SET utf8 COLLATE utf8_general_ci;
```
This means you won't be able to use Emoji's in File Metadata.
*
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.
You can do this by adding the following to the
`[mysqld]`
section of
`/etc/mysql/mariadb.conf.d/50-server.cnf`
:
```
ini
innodb_file_format
=
Barracuda
innodb_file_per_table
=
On
innodb_large_prefix
=
On
innodb_default_row_format
=
dynamic
```
*
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
*
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 group 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
index 8576c7b..df99125 100644
--- a/store/types.go
+++ b/store/types.go
@@ -69,7 +69,7 @@
func (e ErrInvalidMetadataField) Error() string {
//******* Groups
type Group struct {
- Name string `json:"name" gorm:"primary_key"`
+ Name string `json:"name" gorm:"primary_key;size:191"`
CreatedAt time.Time `json:"created"`
UpdatedAt time.Time `json:"updated"`
}
@@ -169,7 +169,7 @@
type File struct {
ID uint64 `json:"id" gorm:"primary_key"`
CreatedAt time.Time `json:"created"`
UpdatedAt time.Time `json:"updated"`
- GroupName string `json:"group" gorm:"not null;index"`
+ GroupName string `json:"group" gorm:"not null;index;size:191"`
Group Group `json:"-" gorm:"association_foreignkey:Name"`
Source FileSource `json:"source" gorm:"embedded;embedded_prefix:source__"`
Metadata FileMetadata `json:"metadata" gorm:"embedded;embedded_prefix:metadata__"`
@@ -194,7 +194,7 @@
type Playlist struct {
ID uint64 `json:"id" gorm:"primary_key"`
CreatedAt time.Time `json:"created"`
UpdatedAt time.Time `json:"updated"`
- GroupName string `json:"group" gorm:"not null;index"`
+ GroupName string `json:"group" gorm:"not null;index;size:191"`
Group Group `json:"-" gorm:"association_foreignkey:Name"`
Entries []PlaylistEntry `json:"entries,omitempty"`
}
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment