preaction / Minion-Backend-mysql

MySQL backend for the 🐙 Minion job runner
Other
7 stars 14 forks source link

Specified key was too long #21

Closed ggl closed 5 years ago

ggl commented 5 years ago

Hello.

Does this backend work with Minion 9.11? I tried to run it but I'm getting

DBD::mysql::st execute failed: Specified key was too long; max key length is 1000 bytes at /opt/perl/perl-5.26.1/lib/site_perl/5.26.1/Mojo/mysql/Migrations.pm line 125.

when I try running it with the mysql backend. Subsequent reruns return this error instead:

DBD::mysql::st execute failed: Duplicate key name 'minion_jobs_state_idx' at /opt/perl/perl-5.26.1/lib/site_perl/5.26.1/Mojo/mysql/Migrations.pm line 125

OS: Darwin Kernel Version 14.5.0 mysql: 10.0.34-MariaDB with MyISAM as the default engine Minion: 9.11 Minion::Backend::mysql: 0.15

Script is attached below (basically the example in the minion POD): minion.txt

preaction commented 5 years ago

It should work. I have no reason to believe it wouldn't.

This error is not related to the Minion version. My best guess is that your database's default charset is a 4-byte charset and the backend is trying to create an index on a column that can be 255 characters long. ( 255 * 4 ) > 1000 so it blows up with this error message.

https://github.com/preaction/Minion-Backend-mysql/blob/master/lib/Minion/Backend/mysql.pm#L999 <- Try changing this line to name VARCHAR(200) NOT NULL, and seeing what happens maybe?

ggl commented 5 years ago

Yes, that's it.

CREATE DATABASE test /!40100 DEFAULT CHARACTER SET utf8mb4 /

Tables are created with the same character set.

preaction commented 5 years ago

Alright, so I should probably reduce that column to 240 characters so that it survives that character encoding.