Update to 1.18.0 Fails #1514

Closed
opened 2025-10-09 17:17:51 +03:00 by OVERLORD · 12 comments
Owner

Originally created by @deeztek on GitHub.

Subject of the issue

Your environment

  • Bitwarden_rs version: 1.16.3
  • Install method: Docker Image
  • Clients used:
  • Reverse proxy and version: Traefik
  • Version of mysql/postgresql: MariaDB 10.5.6
  • Other relevant information: reapplying utf8_general_ci to the database as suggested by #1184 does not seem to help. As a matter of fact the referenced favorites table does not exist at all.

Steps to reproduce

docker-compose down
docker-compose pull
docker-compose up -d

Expected behaviour

Upgrade to 1.18.0

Actual behaviour

Upgrade fails with the logs below.

Relevant logs

Running migration 20200802025025
Executing migration script 20200802025025/up.sql
[2021-01-10 05:55:40.203][bitwarden_rs::util][WARN] Can't connect to database, retrying: DieselMigError.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can\'t create table `bitwarden`.`favorites` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
Originally created by @deeztek on GitHub. <!-- # ### NOTE: Please update to the latest version of bitwarden_rs before reporting an issue! This saves you and us a lot of time and troubleshooting. See: https://github.com/dani-garcia/bitwarden_rs/issues/1180 # ### --> <!-- Please fill out the following template to make solving your problem easier and faster for us. This is only a guideline. If you think that parts are unnecessary for your issue, feel free to remove them. Remember to hide/obfuscate personal and confidential information, such as names, global IP/DNS addresses and especially passwords, if necessary. --> ### Subject of the issue <!-- Describe your issue here.--> ### Your environment <!-- The version number, obtained from the logs or the admin diagnostics page --> <!-- Remember to check your issue on the latest version first! --> * Bitwarden_rs version: 1.16.3 <!-- How the server was installed: Docker image / package / built from source --> * Install method: Docker Image * Clients used: <!-- if applicable --> * Reverse proxy and version: Traefik * Version of mysql/postgresql: MariaDB 10.5.6 * Other relevant information: reapplying utf8_general_ci to the database as suggested by #1184 does not seem to help. As a matter of fact the referenced favorites table does not exist at all. ### Steps to reproduce docker-compose down docker-compose pull docker-compose up -d ### Expected behaviour Upgrade to 1.18.0 ### Actual behaviour Upgrade fails with the logs below. ### Relevant logs ``` Running migration 20200802025025 Executing migration script 20200802025025/up.sql [2021-01-10 05:55:40.203][bitwarden_rs::util][WARN] Can't connect to database, retrying: DieselMigError. [CAUSE] QueryError( DatabaseError( __Unknown, "Can\'t create table `bitwarden`.`favorites` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ```
Author
Owner

@rouben commented on GitHub:

Is this related to #1289?

@rouben commented on GitHub: Is this related to #1289?
Author
Owner

@deeztek commented on GitHub:

@deeztek and @rouben
Could you show the full table contents of __diesel_schema_migrations?

Np. Please see below:

20180114171611 2019-11-05 11:22:46
20180217205753 2019-11-05 11:22:46
20180427155151 2019-11-05 11:22:46
20180508161616 2019-11-05 11:22:46
20180525232323 2019-11-05 11:22:46
20180601112529 2019-11-05 11:22:47
20180711181453 2019-11-05 11:22:47
20180827172114 2019-11-05 11:22:47
20180910111213 2019-11-05 11:22:47
20180919144557 2019-11-05 11:22:47
20181127152651 2019-11-05 11:22:47
20190526216651 2019-11-05 11:22:48
20191010083032 2019-11-05 11:22:48
20191117011009 2020-01-13 11:48:44
20200313205045 2020-03-25 17:20:19
20200409235005 2020-07-04 09:30:30
20200701214531 2021-01-09 08:35:33

@deeztek commented on GitHub: > @deeztek and @rouben > Could you show the full table contents of __diesel_schema_migrations? Np. Please see below: 20180114171611 2019-11-05 11:22:46 20180217205753 2019-11-05 11:22:46 20180427155151 2019-11-05 11:22:46 20180508161616 2019-11-05 11:22:46 20180525232323 2019-11-05 11:22:46 20180601112529 2019-11-05 11:22:47 20180711181453 2019-11-05 11:22:47 20180827172114 2019-11-05 11:22:47 20180910111213 2019-11-05 11:22:47 20180919144557 2019-11-05 11:22:47 20181127152651 2019-11-05 11:22:47 20190526216651 2019-11-05 11:22:48 20191010083032 2019-11-05 11:22:48 20191117011009 2020-01-13 11:48:44 20200313205045 2020-03-25 17:20:19 20200409235005 2020-07-04 09:30:30 20200701214531 2021-01-09 08:35:33
Author
Owner

@BlackDex commented on GitHub:

I don't think so. Foreign key's are a bit of a different issue most of the time.
Unless something has changed in the specific MariaDB/MySQL db version running.

@BlackDex commented on GitHub: I don't think so. Foreign key's are a bit of a different issue most of the time. Unless something has changed in the specific MariaDB/MySQL db version running.
Author
Owner

@deeztek commented on GitHub:

Is this related to #1289?

I looked at that issue and it doesn't look related. I'm using MariaDB. I know the error is related to Foreign Key, however you would get the same error if the favorites table was missing which is precisely the issue here. I looked at the table list and the favorites table is not there.

@deeztek commented on GitHub: > Is this related to #1289? I looked at that issue and it doesn't look related. I'm using MariaDB. I know the error is related to Foreign Key, however you would get the same error if the favorites table was missing which is precisely the issue here. I looked at the table list and the favorites table is not there.
Author
Owner

@BlackDex commented on GitHub:

@deeztek and @rouben
Could you show the full table contents of __diesel_schema_migrations?

@BlackDex commented on GitHub: @deeztek and @rouben Could you show the full table contents of __diesel_schema_migrations?
Author
Owner

@ghost commented on GitHub:

@rouben Originally my tables had utf8mb4_unicode_ci but the database had something e.g. latin1_swedish_ci for some unknown reason. So even though the tables had the correct collation, I still had the issue you had. When I corrected my database collation, it worked perfectly.

I would suggest you try it out. Make a backup, and switch the collations of both the tables and databases to utf8mb4_unicode_ci. It will probably solve the issue you are having.

@ghost commented on GitHub: @rouben Originally my tables had `utf8mb4_unicode_ci` but the database had something e.g. `latin1_swedish_ci` for some unknown reason. So even though the tables had the correct collation, I still had the issue you had. When I corrected my database collation, it worked perfectly. I would suggest you try it out. Make a backup, and switch the collations of both the tables and databases to `utf8mb4_unicode_ci`. It will probably solve the issue you are having.
Author
Owner

@rouben commented on GitHub:

@deeztek and @rouben

Could you show the full table contents of __diesel_schema_migrations?

20180114171611
2020-03-03 00:21:44

20180217205753
2020-03-03 00:21:44

20180427155151
2020-03-03 00:21:44

20180508161616
2020-03-03 00:21:44

20180525232323
2020-03-03 00:21:44

20180601112529
2020-03-03 00:21:44

20180711181453
2020-03-03 00:21:44

20180827172114
2020-03-03 00:21:44

20180910111213
2020-03-03 00:21:44

20180919144557
2020-03-03 00:21:45

20181127152651
2020-03-03 00:21:45

20190526216651
2020-03-03 00:21:45

20191010083032
2020-03-03 00:21:45

20191117011009
2020-03-03 00:21:45

20200313205045
2020-06-03 18:19:08

20200409235005
2020-06-03 18:19:09

20200701214531
2020-12-08 00:49:37

20200802025025
2020-12-08 00:49:37

20201130224000
2021-01-20 16:09:40

20201209173101
2021-01-20 16:09:40

@rouben commented on GitHub: > @deeztek and @rouben > > Could you show the full table contents of __diesel_schema_migrations? 20180114171611 2020-03-03 00:21:44 20180217205753 2020-03-03 00:21:44 20180427155151 2020-03-03 00:21:44 20180508161616 2020-03-03 00:21:44 20180525232323 2020-03-03 00:21:44 20180601112529 2020-03-03 00:21:44 20180711181453 2020-03-03 00:21:44 20180827172114 2020-03-03 00:21:44 20180910111213 2020-03-03 00:21:44 20180919144557 2020-03-03 00:21:45 20181127152651 2020-03-03 00:21:45 20190526216651 2020-03-03 00:21:45 20191010083032 2020-03-03 00:21:45 20191117011009 2020-03-03 00:21:45 20200313205045 2020-06-03 18:19:08 20200409235005 2020-06-03 18:19:09 20200701214531 2020-12-08 00:49:37 20200802025025 2020-12-08 00:49:37 20201130224000 2021-01-20 16:09:40 20201209173101 2021-01-20 16:09:40
Author
Owner

@ghost commented on GitHub:

Evening!

Just now I had the exact same symptoms on my system. The issue was solved when I converted the database to the correct character set. Query I used:

ALTER DATABASE <bitwarden db name> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

All issues were fixed after.

Considering OP states that was already tried, I would suggest OP checks the collation & character set for the users table. Perhaps the database has the correct settings, but the table doesn't?

@ghost commented on GitHub: Evening! Just now I had the exact same symptoms on my system. The issue was solved when I converted the database to the correct character set. Query I used: ``` ALTER DATABASE <bitwarden db name> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ``` All issues were fixed after. Considering OP states that was already tried, I would suggest OP checks the collation & character set for the users table. Perhaps the database has the correct settings, but the table doesn't?
Author
Owner

@rouben commented on GitHub:

Evening!

Just now I had the exact same symptoms on my system. The issue was solved when I converted the database to the correct character set. Query I used:


ALTER DATABASE <bitwarden db name> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

All issues were fixed after.

Considering OP states that was already tried, I would suggest OP checks the collation & character set for the users table. Perhaps the database has the correct settings, but the table doesn't?

What was the schema originally?

Mine is utf8_bin on the database and all the tables.

@rouben commented on GitHub: > Evening! > > > > Just now I had the exact same symptoms on my system. The issue was solved when I converted the database to the correct character set. Query I used: > > ``` > > ALTER DATABASE <bitwarden db name> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; > > ``` > > > > All issues were fixed after. > > > > Considering OP states that was already tried, I would suggest OP checks the collation & character set for the users table. Perhaps the database has the correct settings, but the table doesn't? What was the schema originally? Mine is **utf8_bin** on the database and all the tables.
Author
Owner

@BlackDex commented on GitHub:

Thx. That indicates it stops at creating the favorites table. I will see if i can replicate this.

@BlackDex commented on GitHub: Thx. That indicates it stops at creating the favorites table. I will see if i can replicate this.
Author
Owner

@rouben commented on GitHub:

Maybe running 20200802025025/up.sql manually will yield a more verbose error? Do these also update __diesel_schema_migrations table contents upon successful execution?

@rouben commented on GitHub: Maybe running 20200802025025/up.sql manually will yield a more verbose error? Do these also update __diesel_schema_migrations table contents upon successful execution?
Author
Owner

@BlackDex commented on GitHub:

@deeztek, could you check your collation settings and see if the above solutions could help you?

@BlackDex commented on GitHub: @deeztek, could you check your collation settings and see if the above solutions could help you?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#1514