Migrations cause Postgres warnings because SET CONSTRAINTS can only be used in transaction blocks #696

Closed
opened 2025-10-09 16:47:03 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @spantaleev on GitHub.

Each time Vaultwarden starts, it runs its migrations and those trigger a Postgres warning (logged in the Postgres logs):

WARNING: SET CONSTRAINTS can only be used in transaction blocks

Deployment environment

  • vaultwarden version: 1.29.2
  • Install method: Docker image

  • Clients used: irrelevant

  • Reverse proxy and version: irrelevant

  • MySQL/MariaDB or PostgreSQL version: PostgreSQL v16

  • Other relevant details:

I've found this code to be related: bc26bfa589/src/db/mod.rs (L493)

It doesn't seem like Vaultwarden is affected negatively by this, but it's probably something that should be looked into anyway.

Steps to reproduce

Restart Vaultwarden. On startup, it will run its migrations code and trigger this warning (found in the Postgres logs).

Originally created by @spantaleev on GitHub. Each time Vaultwarden starts, it runs its migrations and those trigger a Postgres warning (logged in the Postgres logs): > WARNING: SET CONSTRAINTS can only be used in transaction blocks ### Deployment environment <!-- ========================================================================================= Preferably, use the `Generate Support String` button on the admin page's Diagnostics tab. That will auto-generate most of the info requested in this section. ========================================================================================= --> <!-- The version number, obtained from the logs (at startup) or the admin diagnostics page --> <!-- This is NOT the version number shown on the web vault, which is versioned separately from vaultwarden --> <!-- Remember to check if your issue exists on the latest version first! --> * vaultwarden version: 1.29.2 <!-- How the server was installed: Docker image, OS package, built from source, etc. --> * Install method: Docker image * Clients used: irrelevant * Reverse proxy and version: irrelevant * MySQL/MariaDB or PostgreSQL version: PostgreSQL v16 * Other relevant details: I've found this code to be related: https://github.com/dani-garcia/vaultwarden/blob/bc26bfa589c007da9b9be37e1172060f38a948b9/src/db/mod.rs#L493 It doesn't seem like Vaultwarden is affected negatively by this, but it's probably something that should be looked into anyway. ### Steps to reproduce Restart Vaultwarden. On startup, it will run its migrations code and trigger this warning (found in the Postgres logs).
OVERLORD added the low priorityenhancement labels 2025-10-09 16:47:03 +03:00
Author
Owner

@stefan0xC commented on GitHub:

According to the comment preceding the statement (and the linked documentation) bc26bfa589/src/db/mod.rs (L487-L492) it does not do anything outside a transaction, so it can be ignored.
(And possible removed since run_pending_migrations will run each migration in its own transaction)

@stefan0xC commented on GitHub: According to the comment preceding the statement (and the linked documentation) https://github.com/dani-garcia/vaultwarden/blob/bc26bfa589c007da9b9be37e1172060f38a948b9/src/db/mod.rs#L487-L492 it does not do anything outside a transaction, so it can be ignored. (And possible removed since `run_pending_migrations` will [run each migration in its own transaction](https://docs.diesel.rs/1.4.x/diesel_migrations/fn.run_pending_migrations.html))
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#696