[GH-ISSUE #759] 'main' panicking at running migrations #519

Closed
opened 2026-03-03 01:30:06 +03:00 by kerem · 24 comments
Owner

Originally created by @flexwie on GitHub (Dec 4, 2019).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/759

Subject of the issue

When runnning the binaries, thread is pannicking at "Running migration 20180114171611"; throwing a formatter error.

Your environment

  • Bitwarden_rs version: latest
  • Install method: build from source
  • Clients used:
  • Reverse proxy and version:
  • Version of mysql/postgresql:
  • Other relevant information:

Steps to reproduce

build and start latest binaries

Relevant logs

Running migration 20180114171611
thread 'main' panicked at 'Can't run migrations: MigrationError(IoError(Custom { kind: Other, error: "formatter error" }))', src/libcore/result.rs:1187:5
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:84
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:61
4: core::fmt::write
at src/libcore/fmt/mod.rs:1030
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1412
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:65
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:50
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:188
9: std::panicking::default_hook
at src/libstd/panicking.rs:205
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:464
11: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:373
12: rust_begin_unwind
at src/libstd/panicking.rs:302
13: core::panicking::panic_fmt
at src/libcore/panicking.rs:82
14: core::result::unwrap_failed
at src/libcore/result.rs:1187
15: bitwarden_rs::migrations::run_migrations
16: bitwarden_rs::main
17: std::rt::lang_start::{{closure}}
18: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:48
19: std::panicking::try::do_call
at src/libstd/panicking.rs:287
20: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:86
21: std::panicking::try
at src/libstd/panicking.rs:265
22: std::panic::catch_unwind
at src/libstd/panic.rs:395
23: std::rt::lang_start_internal
at src/libstd/rt.rs:47
24: main
25: __libc_start_main
26: _start

Originally created by @flexwie on GitHub (Dec 4, 2019). Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/759 <!-- 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 unneccessary for your issue, feel free to remove them. Remember to hide/obfuscate personal and confidential information, such as names, global IP/DNS adresses and especially passwords, if neccessary. --> ### Subject of the issue <!-- Describe your issue here.--> When runnning the binaries, thread is pannicking at "Running migration 20180114171611"; throwing a formatter error. ### Your environment <!-- The version number, obtained from the logs or the admin page --> * Bitwarden_rs version: latest <!-- How the server was installed: Docker image / package / built from source --> * Install method: build from source * Clients used: <!-- if applicable --> * Reverse proxy and version: <!-- if applicable --> * Version of mysql/postgresql: <!-- if applicable --> * Other relevant information: ### Steps to reproduce <!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) and how did you start bitwarden_rs? --> build and start latest binaries ### Relevant logs <!-- Share some logfiles, screenshots or output of relevant programs with us. --> Running migration 20180114171611 thread 'main' panicked at 'Can't run migrations: MigrationError(IoError(Custom { kind: Other, error: "formatter error" }))', src/libcore/result.rs:1187:5 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88 1: backtrace::backtrace::trace_unsynchronized at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:84 3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt at src/libstd/sys_common/backtrace.rs:61 4: core::fmt::write at src/libcore/fmt/mod.rs:1030 5: std::io::Write::write_fmt at src/libstd/io/mod.rs:1412 6: std::sys_common::backtrace::_print at src/libstd/sys_common/backtrace.rs:65 7: std::sys_common::backtrace::print at src/libstd/sys_common/backtrace.rs:50 8: std::panicking::default_hook::{{closure}} at src/libstd/panicking.rs:188 9: std::panicking::default_hook at src/libstd/panicking.rs:205 10: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:464 11: std::panicking::continue_panic_fmt at src/libstd/panicking.rs:373 12: rust_begin_unwind at src/libstd/panicking.rs:302 13: core::panicking::panic_fmt at src/libcore/panicking.rs:82 14: core::result::unwrap_failed at src/libcore/result.rs:1187 15: bitwarden_rs::migrations::run_migrations 16: bitwarden_rs::main 17: std::rt::lang_start::{{closure}} 18: std::rt::lang_start_internal::{{closure}} at src/libstd/rt.rs:48 19: std::panicking::try::do_call at src/libstd/panicking.rs:287 20: __rust_maybe_catch_panic at src/libpanic_unwind/lib.rs:86 21: std::panicking::try at src/libstd/panicking.rs:265 22: std::panic::catch_unwind at src/libstd/panic.rs:395 23: std::rt::lang_start_internal at src/libstd/rt.rs:47 24: main 25: __libc_start_main 26: _start
kerem closed this issue 2026-03-03 01:30:06 +03:00
Author
Owner

@mqus commented on GitHub (Dec 4, 2019):

What were the exact commands you used to build and execute bitwarden_rs? I just tried to build it and then run it using the following commands and it worked without an error.

$ cargo build --release --features sqlite

$ WEB_VAULT_ENABLED=false target/release/bitwarden_rs

(I didn't bother to build and include the vault so I disabled it for the experiment)
Which OS are you running on? I used Archlinux latest.

<!-- gh-comment-id:561896817 --> @mqus commented on GitHub (Dec 4, 2019): What were the exact commands you used to build and execute bitwarden_rs? I just tried to build it and then run it using the following commands and it worked without an error. ```bash $ cargo build --release --features sqlite $ WEB_VAULT_ENABLED=false target/release/bitwarden_rs ``` (I didn't bother to build and include the vault so I disabled it for the experiment) Which OS are you running on? I used Archlinux latest.
Author
Owner

@mqus commented on GitHub (Dec 5, 2019):

Also, as this occurs in the database backend, could you mention which database you chose and the PostgreSql or MySql server version?

A first shot at a fix: You could try to remove the database and let bitwarden_rs add it from scratch, maybe it screwed up in a previous run.

<!-- gh-comment-id:561902169 --> @mqus commented on GitHub (Dec 5, 2019): Also, as this occurs in the database backend, could you mention which database you chose and the PostgreSql or MySql server version? A first shot at a fix: You could try to remove the database and let bitwarden_rs add it from scratch, maybe it screwed up in a previous run.
Author
Owner

@BlackDex commented on GitHub (Dec 5, 2019):

This could also be an issue with the connection to the database backend.
If it doesn't connect, or username/password is incorrect it will fail like this.

<!-- gh-comment-id:562094005 --> @BlackDex commented on GitHub (Dec 5, 2019): This could also be an issue with the connection to the database backend. If it doesn't connect, or username/password is incorrect it will fail like this.
Author
Owner

@flexwie commented on GitHub (Dec 6, 2019):

I deleted bitwardens database and rerun it without success... I can guarantee that the user and password combination is correct!

I am using MariaDB 10.038 on Ubuntu 16.04

<!-- gh-comment-id:562702570 --> @flexwie commented on GitHub (Dec 6, 2019): I deleted bitwardens database and rerun it without success... I can guarantee that the user and password combination is correct! I am using MariaDB 10.038 on Ubuntu 16.04
Author
Owner

@BlackDex commented on GitHub (Dec 6, 2019):

Hmm, i vaguely remember something like this with maria not working and mysql it did. I would have to try it my self again to be sure.

<!-- gh-comment-id:562711277 --> @BlackDex commented on GitHub (Dec 6, 2019): Hmm, i vaguely remember something like this with maria not working and mysql it did. I would have to try it my self again to be sure.
Author
Owner

@pete1450 commented on GitHub (Dec 13, 2019):

I'm seeing the same thing on a fresh self built install with MariaDB 10.3.15. The initial start works fine and creates the tables but if I immediately stop the server and bring it back up I get the error. If I wipe the tables it's all good again but restart gets the error.

Update: If I rebuild it without the migrations it's fine. Temporary solution at least. From what I read I don't understand why they were trying to run at all though.

<!-- gh-comment-id:565292457 --> @pete1450 commented on GitHub (Dec 13, 2019): I'm seeing the same thing on a fresh self built install with MariaDB 10.3.15. The initial start works fine and creates the tables but if I immediately stop the server and bring it back up I get the error. If I wipe the tables it's all good again but restart gets the error. Update: If I rebuild it without the migrations it's fine. Temporary solution at least. From what I read I don't understand why they were trying to run at all though.
Author
Owner

@BlackDex commented on GitHub (Dec 13, 2019):

@pete1450: Well those migrations will run always if the database is empty or if the migration timestamp is different between what is stored in the database and what the bitwarden_rs binary has built-in.

I Just tested it with mysql Ver 14.14 Distrib 5.7.28, for Linux (x86_64) using EditLine wrapper
And i can stop/start/stop/start a self-compiled bitwarden_rs server.

I have to try with MariaDB foo see if that will cause an issue for me, but this seems to just work fine.

<!-- gh-comment-id:565429345 --> @BlackDex commented on GitHub (Dec 13, 2019): @pete1450: Well those migrations will run always if the database is empty or if the migration timestamp is different between what is stored in the database and what the bitwarden_rs binary has built-in. I Just tested it with `mysql Ver 14.14 Distrib 5.7.28, for Linux (x86_64) using EditLine wrapper` And i can stop/start/stop/start a self-compiled bitwarden_rs server. I have to try with MariaDB foo see if that will cause an issue for me, but this seems to just work fine.
Author
Owner

@BlackDex commented on GitHub (Dec 13, 2019):

And i just have tested it with mysql Ver 15.1 Distrib 10.3.21-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2, which also gives no issues at all for me.

Does the mysql user have all the right permissions?

<!-- gh-comment-id:565440376 --> @BlackDex commented on GitHub (Dec 13, 2019): And i just have tested it with `mysql Ver 15.1 Distrib 10.3.21-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2`, which also gives no issues at all for me. Does the mysql user have all the right permissions?
Author
Owner

@BlackDex commented on GitHub (Dec 13, 2019):

I even just build bitwarden_rs with only the mariadb libraries installed and it will use the libmariadb.so instead of libmysqlclient.so and also that works fine without issues.

Could you try the mysql docker build to rule out issues with building?

<!-- gh-comment-id:565475863 --> @BlackDex commented on GitHub (Dec 13, 2019): I even just build bitwarden_rs with only the mariadb libraries installed and it will use the libmariadb.so instead of libmysqlclient.so and also that works fine without issues. Could you try the mysql docker build to rule out issues with building?
Author
Owner

@flexwie commented on GitHub (Dec 31, 2019):

Sorry for coming back at you so late. I just created a new user with grant all on bitwarden.* to 'user'@'%' identified by 'password'; on a newly created database and still get the same error.
I'm running Ver 15.1 Distrib 10.1.43-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 as a quite fresh installation.

I will try the docker build tomorrow and report back.

<!-- gh-comment-id:569918525 --> @flexwie commented on GitHub (Dec 31, 2019): Sorry for coming back at you so late. I just created a new user with `grant all on bitwarden.* to 'user'@'%' identified by 'password';` on a newly created database and still get the same error. I'm running `Ver 15.1 Distrib 10.1.43-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2` as a quite fresh installation. I will try the docker build tomorrow and report back.
Author
Owner

@xe5700 commented on GitHub (Mar 11, 2020):

I have same issue with mariadb Ver 15.1 Distrib 10.5.1-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2.

<!-- gh-comment-id:597857991 --> @xe5700 commented on GitHub (Mar 11, 2020): I have same issue with mariadb Ver 15.1 Distrib 10.5.1-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2.
Author
Owner

@nemchik commented on GitHub (Mar 18, 2020):

I'm using bitwardenrs/server-mysql with linuxserver/mariadb and I have this issue with bw version 1.14, but reverting back to the 1.13.1 image seems to get it working again.

<!-- gh-comment-id:600654426 --> @nemchik commented on GitHub (Mar 18, 2020): I'm using `bitwardenrs/server-mysql` with `linuxserver/mariadb` and I have this issue with bw version 1.14, but reverting back to the 1.13.1 image seems to get it working again.
Author
Owner

@nemchik commented on GitHub (Mar 18, 2020):

Here's the log from my 1.14 container (where I saw the error)

/--------------------------------------------------------------------\
|                       Starting Bitwarden_RS                        |
|                       Version 1.14-dce054e6                        |
|--------------------------------------------------------------------|
| This is an *unofficial* Bitwarden implementation, DO NOT use the   |
| official channels to report bugs/features, regardless of client.   |
| Report URL: https://github.com/dani-garcia/bitwarden_rs/issues/new |
\--------------------------------------------------------------------/

Running migration 20200313205045
Executing migration script [2020-03-18 08:55:39][panic][ERROR] thread 'main' panicked at 'Can't run migrations: MigrationError(IoError(Custom { kind: Other, error: "formatter error" }))': src/main.rs:326
   0: bitwarden_rs::init_logging::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   2: rust_begin_unwind
             at src/libstd/panicking.rs:378
   3: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   4: core::option::expect_none_failed
             at src/libcore/option.rs:1211
   5: bitwarden_rs::migrations::run_migrations
   6: bitwarden_rs::main
   7: std::rt::lang_start::{{closure}}
   8: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
      std::panicking::try::do_call
             at src/libstd/panicking.rs:303
   9: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  10: std::panicking::try
             at src/libstd/panicking.rs:281
      std::panic::catch_unwind
             at src/libstd/panic.rs:394
      std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  11: main
  12: __libc_start_main
  13: _start

<!-- gh-comment-id:600657935 --> @nemchik commented on GitHub (Mar 18, 2020): Here's the log from my 1.14 container (where I saw the error) ``` /--------------------------------------------------------------------\ | Starting Bitwarden_RS | | Version 1.14-dce054e6 | |--------------------------------------------------------------------| | This is an *unofficial* Bitwarden implementation, DO NOT use the | | official channels to report bugs/features, regardless of client. | | Report URL: https://github.com/dani-garcia/bitwarden_rs/issues/new | \--------------------------------------------------------------------/ Running migration 20200313205045 Executing migration script [2020-03-18 08:55:39][panic][ERROR] thread 'main' panicked at 'Can't run migrations: MigrationError(IoError(Custom { kind: Other, error: "formatter error" }))': src/main.rs:326 0: bitwarden_rs::init_logging::{{closure}} 1: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:474 2: rust_begin_unwind at src/libstd/panicking.rs:378 3: core::panicking::panic_fmt at src/libcore/panicking.rs:85 4: core::option::expect_none_failed at src/libcore/option.rs:1211 5: bitwarden_rs::migrations::run_migrations 6: bitwarden_rs::main 7: std::rt::lang_start::{{closure}} 8: std::rt::lang_start_internal::{{closure}} at src/libstd/rt.rs:52 std::panicking::try::do_call at src/libstd/panicking.rs:303 9: __rust_maybe_catch_panic at src/libpanic_unwind/lib.rs:86 10: std::panicking::try at src/libstd/panicking.rs:281 std::panic::catch_unwind at src/libstd/panic.rs:394 std::rt::lang_start_internal at src/libstd/rt.rs:51 11: main 12: __libc_start_main 13: _start ```
Author
Owner

@BlackDex commented on GitHub (Mar 18, 2020):

Well, this is related to using the beta version of MariaDB 10.5. Using MariaDB 10.4 has no issues.
Since 10.5 is beta i suggest to revert it back to the latest stable when possible.

<!-- gh-comment-id:600724220 --> @BlackDex commented on GitHub (Mar 18, 2020): Well, this is related to using the beta version of MariaDB 10.5. Using MariaDB 10.4 has no issues. Since 10.5 is beta i suggest to revert it back to the latest stable when possible.
Author
Owner

@BlackDex commented on GitHub (Mar 18, 2020):

I created a fix for this so that during the migrations (creating and updating the base of the database) the Foreign Key Check is disabled. Which seems to be enabled by default in MariaDB 10.5.

<!-- gh-comment-id:600757399 --> @BlackDex commented on GitHub (Mar 18, 2020): I created a fix for this so that during the migrations (creating and updating the base of the database) the Foreign Key Check is disabled. Which seems to be enabled by default in MariaDB 10.5.
Author
Owner

@nemchik commented on GitHub (Mar 18, 2020):

$ docker exec mariadb mariadb --version
mariadb  Ver 15.1 Distrib 10.4.12-MariaDB, for debian-linux-
gnu (x86_64) using readline 5.2

It doesn't seem like I'm using mariadb 10.5

<!-- gh-comment-id:600786053 --> @nemchik commented on GitHub (Mar 18, 2020): ``` $ docker exec mariadb mariadb --version mariadb Ver 15.1 Distrib 10.4.12-MariaDB, for debian-linux- gnu (x86_64) using readline 5.2 ``` It doesn't seem like I'm using mariadb 10.5
Author
Owner

@BlackDex commented on GitHub (Mar 18, 2020):

Maybe the same check is enabled in your configuration or mariadb version by default. In anyway it should be fixed in the next build.

<!-- gh-comment-id:600788291 --> @BlackDex commented on GitHub (Mar 18, 2020): Maybe the same check is enabled in your configuration or mariadb version by default. In anyway it should be fixed in the next build.
Author
Owner

@nemchik commented on GitHub (Mar 18, 2020):

Awesome, thanks! I'll test the next build once I see it up!

<!-- gh-comment-id:600790408 --> @nemchik commented on GitHub (Mar 18, 2020): Awesome, thanks! I'll test the next build once I see it up!
Author
Owner

@nemchik commented on GitHub (Apr 17, 2020):

I was able to get upgraded today. I tried Version 1.14.2-5a390a97 and saw the following in docker logs bitwarden

/--------------------------------------------------------------------\
|                       Starting Bitwarden_RS                        |
|                      Version 1.14.2-5a390a97                       |
|--------------------------------------------------------------------|
| This is an *unofficial* Bitwarden implementation, DO NOT use the   |
| official channels to report bugs/features, regardless of client.   |
| Report URL: https://github.com/dani-garcia/bitwarden_rs/issues/new |
\--------------------------------------------------------------------/

Running migration 20200313205045
Executing migration script 20200313205045/up.sql
[2020-04-17 10:48:58][panic][ERROR] thread 'main' panicked at 'Can't run migrations: QueryError(DatabaseError(__Unknown, "Table \'org_policies\' already exists"))': src/main.rs:336
   0: bitwarden_rs::init_logging::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:515
   2: rust_begin_unwind
             at src/libstd/panicking.rs:419
   3: core::panicking::panic_fmt
             at src/libcore/panicking.rs:111
   4: core::option::expect_none_failed
             at src/libcore/option.rs:1268
   5: bitwarden_rs::migrations::run_migrations
   6: bitwarden_rs::main
   7: std::rt::lang_start::{{closure}}
   8: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
      std::panicking::try::do_call
             at src/libstd/panicking.rs:331
      std::panicking::try
             at src/libstd/panicking.rs:274
      std::panic::catch_unwind
             at src/libstd/panic.rs:394
      std::rt::lang_start_internal
             at src/libstd/rt.rs:51
   9: main
  10: __libc_start_main
  11: _start

I investigated using phpmyadmin and found there was a org_policies table in my database but it was empty (no rows). I made a backup of the database (used phpmyadmin's export option) and then dropped the table and restarted the container and everything seems to be working now.

Anyone else having this issue might also have success trying 1.14.2 or newer but may also need to drop the org_policies table (be sure to make backups!).

<!-- gh-comment-id:615332239 --> @nemchik commented on GitHub (Apr 17, 2020): I was able to get upgraded today. I tried `Version 1.14.2-5a390a97` and saw the following in `docker logs bitwarden` ``` /--------------------------------------------------------------------\ | Starting Bitwarden_RS | | Version 1.14.2-5a390a97 | |--------------------------------------------------------------------| | This is an *unofficial* Bitwarden implementation, DO NOT use the | | official channels to report bugs/features, regardless of client. | | Report URL: https://github.com/dani-garcia/bitwarden_rs/issues/new | \--------------------------------------------------------------------/ Running migration 20200313205045 Executing migration script 20200313205045/up.sql [2020-04-17 10:48:58][panic][ERROR] thread 'main' panicked at 'Can't run migrations: QueryError(DatabaseError(__Unknown, "Table \'org_policies\' already exists"))': src/main.rs:336 0: bitwarden_rs::init_logging::{{closure}} 1: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:515 2: rust_begin_unwind at src/libstd/panicking.rs:419 3: core::panicking::panic_fmt at src/libcore/panicking.rs:111 4: core::option::expect_none_failed at src/libcore/option.rs:1268 5: bitwarden_rs::migrations::run_migrations 6: bitwarden_rs::main 7: std::rt::lang_start::{{closure}} 8: std::rt::lang_start_internal::{{closure}} at src/libstd/rt.rs:52 std::panicking::try::do_call at src/libstd/panicking.rs:331 std::panicking::try at src/libstd/panicking.rs:274 std::panic::catch_unwind at src/libstd/panic.rs:394 std::rt::lang_start_internal at src/libstd/rt.rs:51 9: main 10: __libc_start_main 11: _start ``` I investigated using phpmyadmin and found there was a `org_policies` table in my database but it was empty (no rows). I made a backup of the database (used phpmyadmin's export option) and then dropped the table and restarted the container and everything seems to be working now. Anyone else having this issue might also have success trying `1.14.2` or newer but may also need to drop the `org_policies` table (be sure to make backups!).
Author
Owner

@Gurkengewuerz commented on GitHub (May 13, 2020):

I'm seeing the same thing on a fresh self built install with MariaDB 10.3.15. The initial start works fine and creates the tables but if I immediately stop the server and bring it back up I get the error. If I wipe the tables it's all good again but restart gets the error.

Update: If I rebuild it without the migrations it's fine. Temporary solution at least. From what I read I don't understand why they were trying to run at all though.

I am running the newest bitwarden release with sqlite support and it works like a charm, but if i migrate to mysql i get the exact error like @pete1450.
I built the newest version and ran bitwarden_rs once to create the schema. The table __diesel_schema_migrations created and also has the right content but if i rerun bitwarden_rs, diesel wants to create the schema again.

I am running bitwarden_rs in an lxc container on Debian 9 and mysql Ver 15.1 Distrib 10.4.12-MariaDB, for Linux (x86_64) using readline 5.1 on alpine 3.11 also in an lxc container.

My first thought was that the time on both server were incorrect but this isnt the case.

<!-- gh-comment-id:627994104 --> @Gurkengewuerz commented on GitHub (May 13, 2020): > I'm seeing the same thing on a fresh self built install with MariaDB 10.3.15. The initial start works fine and creates the tables but if I immediately stop the server and bring it back up I get the error. If I wipe the tables it's all good again but restart gets the error. > > Update: If I rebuild it without the migrations it's fine. Temporary solution at least. From what I read I don't understand why they were trying to run at all though. I am running the newest bitwarden release with sqlite support and it works like a charm, but if i migrate to mysql i get the exact error like @pete1450. I built the newest version and ran bitwarden_rs once to create the schema. The table ```__diesel_schema_migrations``` created and also has the right content but if i rerun bitwarden_rs, diesel wants to create the schema again. I am running bitwarden_rs in an lxc container on Debian 9 and ```mysql Ver 15.1 Distrib 10.4.12-MariaDB, for Linux (x86_64) using readline 5.1``` on alpine 3.11 also in an lxc container. My first thought was that the time on both server were incorrect but this isnt the case.
Author
Owner

@Gurkengewuerz commented on GitHub (May 13, 2020):

If I compile bitwarden_rs without migrations the server will start of course. Nevertheless I have a very strange behaviour. For instance I can't log in. Does it have something to do with WAL? In SQLite it was enabled (to my knowledge) and now it was disabled.

<!-- gh-comment-id:628003916 --> @Gurkengewuerz commented on GitHub (May 13, 2020): If I compile bitwarden_rs without migrations the server will start of course. Nevertheless I have a very strange behaviour. For instance I can't log in. Does it have something to do with WAL? In SQLite it was enabled (to my knowledge) and now it was disabled.
Author
Owner

@jivanpal commented on GitHub (May 29, 2020):

I have a seemingly similar issue on Ubuntu 18.04 with MariaDB 10.1.44 (version from the Ubuntu repos).

Running Docker image bitwardenrs/server-mysql via docker-compose with network_mode: "host" to allow connection to a local MariaDB server. After first run, a table called __diesel_schema_migrations is present, but it contains no data. This is a fresh instance of Bitwarden with no pre-existing /data folder. The database bitwarden is using character set utf8mb4 and collation utf8mb4_unicode_ci.

docker-compose.yml

version: "3"

services:
  bitwarden:
    container_name: bitwarden
    image: bitwardenrs/server-mysql
    restart: always
    volumes:
      - ./data:/data
    network_mode: "host"
    environment:
      WEBSOCKET_ENABLED: "true"
      SIGNUPS_ALLOWED:   "true"
      DATABASE_URL:      "mysql://bitwarden:password@127.0.0.1:3306/bitwarden"
      ROCKET_PORT:       8080

MariaDB privileges

MariaDB [(none)]> SHOW GRANTS FOR bitwarden@'%';
+----------------------------------------------------------------------------------------------------------+
| Grants for bitwarden@%                                                                                   |
+----------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'bitwarden'@'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT ALL PRIVILEGES ON `bitwarden`.* TO 'bitwarden'@'%'                                                 |
+----------------------------------------------------------------------------------------------------------+

Output from bitwarden container on first run using docker-compose up

Creating bitwarden ... done
Attaching to bitwarden
bitwarden    | /--------------------------------------------------------------------\
bitwarden    | |                       Starting Bitwarden_RS                        |
bitwarden    | |                      Version 1.14.2-4eee6e7a                       |
bitwarden    | |--------------------------------------------------------------------|
bitwarden    | | This is an *unofficial* Bitwarden implementation, DO NOT use the   |
bitwarden    | | official channels to report bugs/features, regardless of client.   |
bitwarden    | | Send usage/configuration questions or feature requests to:         |
bitwarden    | |   https://bitwardenrs.discourse.group/                             |
bitwarden    | | Report suspected bugs/issues in the software itself at:            |
bitwarden    | |   https://github.com/dani-garcia/bitwarden_rs/issues/new           |
bitwarden    | \--------------------------------------------------------------------/
bitwarden    | 
bitwarden    | [2020-05-29 06:12:26][bitwarden_rs][INFO] JWT keys don't exist, checking if OpenSSL is available...
bitwarden    | OpenSSL 1.1.1d  10 Sep 2019
bitwarden    | [2020-05-29 06:12:26][bitwarden_rs][INFO] OpenSSL detected, creating keys...
bitwarden    | Generating RSA private key, 2048 bit long modulus (2 primes)
bitwarden    | ..........................................+++++
bitwarden    | .................................................................................................................................................................................................................................................................................................+++++
bitwarden    | e is 65537 (0x010001)
bitwarden    | writing RSA key
bitwarden    | writing RSA key
bitwarden    | [2020-05-29 06:12:26][bitwarden_rs][INFO] Keys created correctly.
bitwarden    | Running migration 20180114171611
bitwarden    | Executing migration script 20180114171611/up.sql
bitwarden    | [2020-05-29 06:12:26][panic][ERROR] thread 'main' panicked at 'Can't run migrations: QueryError(DatabaseError(__Unknown, "Specified key was too long; max key length is 767 bytes"))': src/main.rs:333
bitwarden    |    0: bitwarden_rs::init_logging::{{closure}}
bitwarden    |    1: std::panicking::rust_panic_with_hook
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:481
bitwarden    |    2: rust_begin_unwind
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:385
bitwarden    |    3: core::panicking::panic_fmt
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libcore/panicking.rs:89
bitwarden    |    4: core::option::expect_none_failed
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libcore/option.rs:1272
bitwarden    |    5: bitwarden_rs::migrations::run_migrations
bitwarden    |    6: bitwarden_rs::main
bitwarden    |    7: std::rt::lang_start::{{closure}}
bitwarden    |    8: std::rt::lang_start_internal::{{closure}}
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/rt.rs:52
bitwarden    |       std::panicking::try::do_call
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:297
bitwarden    |       std::panicking::try
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:274
bitwarden    |       std::panic::catch_unwind
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panic.rs:394
bitwarden    |       std::rt::lang_start_internal
bitwarden    |              at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/rt.rs:51
bitwarden    |    9: main
bitwarden    |   10: __libc_start_main
bitwarden    |   11: _start
bitwarden    | 
<!-- gh-comment-id:635781918 --> @jivanpal commented on GitHub (May 29, 2020): I have a seemingly similar issue on Ubuntu 18.04 with MariaDB 10.1.44 (version from the Ubuntu repos). Running Docker image `bitwardenrs/server-mysql` via `docker-compose` with `network_mode: "host"` to allow connection to a local MariaDB server. After first run, a table called `__diesel_schema_migrations` is present, but it contains no data. This is a fresh instance of Bitwarden with no pre-existing `/data` folder. The database `bitwarden` is using character set `utf8mb4` and collation `utf8mb4_unicode_ci`. ### `docker-compose.yml` ``` version: "3" services: bitwarden: container_name: bitwarden image: bitwardenrs/server-mysql restart: always volumes: - ./data:/data network_mode: "host" environment: WEBSOCKET_ENABLED: "true" SIGNUPS_ALLOWED: "true" DATABASE_URL: "mysql://bitwarden:password@127.0.0.1:3306/bitwarden" ROCKET_PORT: 8080 ``` ### MariaDB privileges ``` MariaDB [(none)]> SHOW GRANTS FOR bitwarden@'%'; +----------------------------------------------------------------------------------------------------------+ | Grants for bitwarden@% | +----------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'bitwarden'@'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' | | GRANT ALL PRIVILEGES ON `bitwarden`.* TO 'bitwarden'@'%' | +----------------------------------------------------------------------------------------------------------+ ``` ### Output from `bitwarden` container on first run using `docker-compose up` ``` Creating bitwarden ... done Attaching to bitwarden bitwarden | /--------------------------------------------------------------------\ bitwarden | | Starting Bitwarden_RS | bitwarden | | Version 1.14.2-4eee6e7a | bitwarden | |--------------------------------------------------------------------| bitwarden | | This is an *unofficial* Bitwarden implementation, DO NOT use the | bitwarden | | official channels to report bugs/features, regardless of client. | bitwarden | | Send usage/configuration questions or feature requests to: | bitwarden | | https://bitwardenrs.discourse.group/ | bitwarden | | Report suspected bugs/issues in the software itself at: | bitwarden | | https://github.com/dani-garcia/bitwarden_rs/issues/new | bitwarden | \--------------------------------------------------------------------/ bitwarden | bitwarden | [2020-05-29 06:12:26][bitwarden_rs][INFO] JWT keys don't exist, checking if OpenSSL is available... bitwarden | OpenSSL 1.1.1d 10 Sep 2019 bitwarden | [2020-05-29 06:12:26][bitwarden_rs][INFO] OpenSSL detected, creating keys... bitwarden | Generating RSA private key, 2048 bit long modulus (2 primes) bitwarden | ..........................................+++++ bitwarden | .................................................................................................................................................................................................................................................................................................+++++ bitwarden | e is 65537 (0x010001) bitwarden | writing RSA key bitwarden | writing RSA key bitwarden | [2020-05-29 06:12:26][bitwarden_rs][INFO] Keys created correctly. bitwarden | Running migration 20180114171611 bitwarden | Executing migration script 20180114171611/up.sql bitwarden | [2020-05-29 06:12:26][panic][ERROR] thread 'main' panicked at 'Can't run migrations: QueryError(DatabaseError(__Unknown, "Specified key was too long; max key length is 767 bytes"))': src/main.rs:333 bitwarden | 0: bitwarden_rs::init_logging::{{closure}} bitwarden | 1: std::panicking::rust_panic_with_hook bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:481 bitwarden | 2: rust_begin_unwind bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:385 bitwarden | 3: core::panicking::panic_fmt bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libcore/panicking.rs:89 bitwarden | 4: core::option::expect_none_failed bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libcore/option.rs:1272 bitwarden | 5: bitwarden_rs::migrations::run_migrations bitwarden | 6: bitwarden_rs::main bitwarden | 7: std::rt::lang_start::{{closure}} bitwarden | 8: std::rt::lang_start_internal::{{closure}} bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/rt.rs:52 bitwarden | std::panicking::try::do_call bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:297 bitwarden | std::panicking::try bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panicking.rs:274 bitwarden | std::panic::catch_unwind bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/panic.rs:394 bitwarden | std::rt::lang_start_internal bitwarden | at rustc/99cb9ccb9ca2067ad6e60508e3d52da77396b2f1/src/libstd/rt.rs:51 bitwarden | 9: main bitwarden | 10: __libc_start_main bitwarden | 11: _start bitwarden | ```
Author
Owner

@jivanpal commented on GitHub (May 30, 2020):

Apologies, my issue is unrelated and now resolved. For those who may stumble across my comment in future:

The issue I'm encountering is due to the field bitwarden.users.email being VARCHAR(255) UNIQUE, thus being a key of maximum length 255 characters, plus a terminating null byte, which in conjunction with the character set being utf8mb4, results in a maximum field size of 1021 bytes. This exceeds the default prefix length in MariaDB 10.1 InnoDB tables of 767 bytes.

To resolve this, you can either use a smaller character set like utf8 (which, at max. 3 bytes per char, results in max. field length 766 bytes; though utf8 is highly unrecommended), or enable large prefixes (which also requires using dynamic rows, switching the InnoDB file format from Antelope to Barracuda, and using one file per InnoDB table). See here for required settings.

I believe no such change is needed for MariaDB 10.2 or later.

<!-- gh-comment-id:636247502 --> @jivanpal commented on GitHub (May 30, 2020): Apologies, my issue is unrelated and now resolved. For those who may stumble across my comment in future: The issue I'm encountering is due to the field `bitwarden.users.email` being `VARCHAR(255) UNIQUE`, thus being a key of maximum length 255 characters, plus a terminating null byte, which in conjunction with the character set being `utf8mb4`, results in a maximum field size of 1021 bytes. This exceeds the default prefix length in MariaDB 10.1 InnoDB tables of 767 bytes. To resolve this, you can either use a smaller character set like `utf8` (which, at max. 3 bytes per char, results in max. field length 766 bytes; though `utf8` is highly unrecommended), or enable large prefixes (which also requires using dynamic rows, switching the InnoDB file format from Antelope to Barracuda, and using one file per InnoDB table). [See here for required settings.](https://stackoverflow.com/a/52778785/9996911) I believe no such change is needed for MariaDB 10.2 or later.
Author
Owner

@BlackDex commented on GitHub (Oct 3, 2020):

There have been several database handling changes done since this report. Most of the regarding mysql/mariadb and foreign keys. Closing this one. Please open a new one when needed.

<!-- gh-comment-id:703176738 --> @BlackDex commented on GitHub (Oct 3, 2020): There have been several database handling changes done since this report. Most of the regarding mysql/mariadb and foreign keys. Closing this one. Please open a new one when needed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vaultwarden#519
No description provided.