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

Database migration to 1.17.0 fails on mariadb #1182

Closed
ToeiRei opened this issue Oct 11, 2020 · 7 comments
Closed

Database migration to 1.17.0 fails on mariadb #1182

ToeiRei opened this issue Oct 11, 2020 · 7 comments
Assignees

Comments

@ToeiRei
Copy link

ToeiRei commented Oct 11, 2020

Subject of the issue

#1005 - Can't create table bitwarden.favorites (errno: 150 "Foreign key constraint is incorrectly formed")

Your environment

  • Bitwarden_rs version:
    1.16.3
  • Install method: docker-compose using bitwardenrs/server-mysql
  • Clients used:
  • Reverse proxy and version:
  • Version of mysql/postgresql: 10.5.6-MariaDB-1:10.5.6+maria~buster - mariadb.org binary distribution
  • Other relevant information:

Steps to reproduce

  1. Install 1.16.3
  2. Update to 1.17.0

Expected behaviour

I would expect the database migration to work

Actual behaviour

Docker container looped on starting the migrations. Trying to run it manually it said #1005 - Can't create table `bitwarden`.`favorites` (errno: 150 "Foreign key constraint is incorrectly formed")

which is related to

CREATE TABLE favorites (
  user_uuid   CHAR(36) NOT NULL REFERENCES users(uuid),
  cipher_uuid CHAR(36) NOT NULL REFERENCES ciphers(uuid),

  PRIMARY KEY (user_uuid, cipher_uuid)
);

in the up script

Relevant logs

@BlackDex
Copy link
Collaborator

This is weird, i just did the exact same, and have no issues.

Also using the same mariadb version

mariadb  Ver 15.1 Distrib 10.5.6-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

It is also strange that you can see these error's at all, because foreign-key checking is disabled during migrations because the migrations could create these issues when the order is not completely ok, or we need to do some specials stuff like migrating some data from table x to y.

If you start the server again, does it still produce the same error?
And what if you restart MariaDB first?

@ToeiRei
Copy link
Author

ToeiRei commented Oct 11, 2020

image

That's all I get - even with a restart - no matter if I restart rancherOS or the mariaDB debian container

@BlackDex
Copy link
Collaborator

Wel that is strange. It looks like it is trying to retry it a few times.

@ToeiRei
Copy link
Author

ToeiRei commented Oct 11, 2020

I got into the error and I think I got a clue: Collation mismatches. Not a big deal.

@ToeiRei ToeiRei closed this as completed Oct 11, 2020
@BlackDex BlackDex self-assigned this Oct 11, 2020
@BlackDex
Copy link
Collaborator

Great that you have find the solution.
Could the collation setting being something we need to check, verify or warn on?

@ToeiRei
Copy link
Author

ToeiRei commented Oct 11, 2020

I would suggest verifying those wouldn't hurt. In my case I think it happened via migrating via various MySQL/MariaDB hosts...

@BlackDex
Copy link
Collaborator

Thanks, i have added this to the meta feature request #246

@BlackDex BlackDex mentioned this issue Oct 12, 2020
61 tasks
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

2 participants