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 3.0.0 Fails with Max Key Length Error #1358

Closed
timothystewart6 opened this issue Jan 30, 2022 · 10 comments
Closed

Upgrade to 3.0.0 Fails with Max Key Length Error #1358

timothystewart6 opened this issue Jan 30, 2022 · 10 comments
Labels

Comments

@timothystewart6
Copy link

How Shlink is set-up

  • Shlink Version: 2.10.3 -> 3.0.0
  • PHP Version: version that ships with 2.10.3 container
  • How do you serve Shlink: Self-hosted Docker image
  • Database engine used: MySQL

Summary

Upgrade fails with

db:migrate
An exception occurred while executing a query: SQLSTATE[42000]: Syntax error access violation: 1071 Specified key was too long; max key length is too long; max key length is 767 bytes

Current behavior

Crashloop

Expected behavior

Upgrade, no crashloop

How to reproduce

Upgraded container from 2.10.3 to 3.3.0

@acelaya acelaya added this to the 3.0.1 milestone Jan 30, 2022
@acelaya
Copy link
Member

acelaya commented Jan 30, 2022

In order to fully support emojis, Shlink 3.0.0 changes the charset for some fields from utf8 to utf8mb4, which can potentially increase the size needed to store some characters.

Probably some of those fields has or is part of some key that I missed.

I'll check which one is it.

@acelaya
Copy link
Member

acelaya commented Feb 2, 2022

So, I have checked which of the fields getting updated to utf8mb4 have an index, and only the short_code and import_original_short_code columns in short_urls table, and the name column in tags table fulfill this condition.

The thing is that those should supposedly be pretty short, however, could it be that for you any of those has a very long value in some of the entries?

Also, could you try passing the env var SHELL_VERBOSITY=3 to the docker image? It should print more stuff when the error occurs.

@acelaya acelaya removed this from the 3.0.1 milestone Feb 4, 2022
@timothystewart6
Copy link
Author

Hi and thank you! I check and my longest short code is 20 characters. I can set shell verbosity the next time I attempt the upgrade however need to accommodate for it being down.

@acelaya
Copy link
Member

acelaya commented Feb 7, 2022

Something I forgot to ask. What MySQL version are you using?

@timothystewart6
Copy link
Author

Sorry, something I should have included. 5.6

@acelaya
Copy link
Member

acelaya commented Feb 7, 2022

That might be related. I have read that in versions older than 5.7, the fields which are part of the keys should have a maximum length of 191, otherwise it can throw this error even if there are no value longer than that.

Some of the fields I mentioned have a length of 255, so that might be the problem.

I'll try to reproduce this with MySQL 5.6 and let you know.

@acelaya
Copy link
Member

acelaya commented Feb 7, 2022

Confirmed. This happens only with MySQL 5.6

@timothystewart6 I would suggest updating to MySQL 5.7, as 5.6 is no longer actively supported.

@timothystewart6
Copy link
Author

Thank you and sorry. Will migrate soon. I used this version because another old app requires it, missed that Postgres was supported in the docs or I would have just used that. Sorry to waste your time. Thanks for a great product!

@acelaya
Copy link
Member

acelaya commented Feb 7, 2022

No worries! I'm just glad to know what's the root cause.

@acelaya acelaya closed this as completed Feb 7, 2022
@timothystewart6
Copy link
Author

Just reporting back. I ended up moving to Postgres (thanks to your guide on moving instances) and everything is working after the upgrade. I did lost my stats because of an error with max size during the transfer but getting on Postgres was more important than a legacy version of mysql. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants