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

Mysql backend table creation error using InnoDB and utf8 charset #512

Closed
drampelt opened this issue Aug 10, 2015 · 6 comments
Closed

Mysql backend table creation error using InnoDB and utf8 charset #512

drampelt opened this issue Aug 10, 2015 · 6 comments

Comments

@drampelt
Copy link
Contributor

When using a mysql database with the utf8 charset and InnoDB engine, vault fails to create the table:

Error initializing backend of type mysql: failed to create mysql table: Error 1071: Specified key was too long; max key length is 767 bytes

After some research, I discovered that this is due to the 767 byte limit of InnoDB prefixes. So the issue is that the primary key (vault_key) is a varchar with length 512, exceeding the 767 byte limit as mysql use 3 bytes per character in utf8.

I tried creating the table manually with a smaller length (255) that would fit in this limit, but unfortunately mysql still validates the size even when using CREATE TABLE IF NOT EXISTS and the table does already exist.

@sethvargo sethvargo added the bug label Aug 10, 2015
@armon
Copy link
Member

armon commented Aug 11, 2015

@drampelt Can you try changing the type to varbinary? I don't think we actually need to care about the UTF encoding and that will save us some bytes. Go only works in UTF internally anyways.

@drampelt
Copy link
Contributor Author

Thanks for the suggestion, the table creates fine with varbinary(512). I'm not sure if vault works with it however as I haven't been able to get it compiling locally yet.

@drampelt
Copy link
Contributor Author

Ok got vault working locally and as far as I can tell everything is working great with the primary key being varbinary(512)

@drampelt
Copy link
Contributor Author

Created pull request #522 to solve this

@armon armon closed this as completed in 4993415 Aug 13, 2015
armon added a commit that referenced this issue Aug 13, 2015
Use varbinary instead of varchar for mysql, fixes #512
@dle-fr
Copy link
Contributor

dle-fr commented Oct 16, 2018

Still happening when using HA with Mysql Backend:

Error initializing storage of type mysql: failed to create mysql table: Error 1071: Specified key was too long; max key length is 767 bytes

The vault table exists, but does HA mode try to create another table to store HA lock or something? (I didn't dig into the code)

To reproduce, in conf file, just add ha_enabled = "true" in storage "mysql" section.

@jefferai
Copy link
Member

I would suggest filing a new bug about this and then linking to it from the PR that added MySQL HA support.

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

No branches or pull requests

5 participants