[PR #6989] [MERGED] Change SQLite backup to use VACUUM INTO query #8771

Closed
opened 2026-04-16 12:37:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/6989
Author: @getaaron
Created: 3/22/2026
Status: Merged
Merged: 4/5/2026
Merged by: @dani-garcia

Base: mainHead: fix-backup-memory


📝 Commits (2)

  • 668f1bd Refactor SQLite backup to use VACUUM INTO query
  • 717ebfb Fix VACUUM INTO query error handling

📊 Changes

1 file changed (+7 additions, -11 deletions)

View changed files

📝 src/db/mod.rs (+7 -11)

📄 Description

https://github.com/dani-garcia/vaultwarden/pull/6279 introduced several great improvements, but replaced VACUUM INTO with serialize_database_to_buffer() which is less efficient and loads the whole DB into RAM. This may be contributing to an increase in OOM errors which I have noticed in small vaultwarden deployments with 256MB RAM.

This PR reverts the serialize_database_to_buffer() change back into a VACUUM INTO query while keeping the other improvements from that PR. I also used .bind::<Text, _>(&backup_file) instead of the previous format!("VACUUM INTO '{}'", backup_file) to prevent theoretical SQL injection (even though path is trusted), let me know if you prefer the format! approach and I can switch it


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/6989 **Author:** [@getaaron](https://github.com/getaaron) **Created:** 3/22/2026 **Status:** ✅ Merged **Merged:** 4/5/2026 **Merged by:** [@dani-garcia](https://github.com/dani-garcia) **Base:** `main` ← **Head:** `fix-backup-memory` --- ### 📝 Commits (2) - [`668f1bd`](https://github.com/dani-garcia/vaultwarden/commit/668f1bdedfe5eac485925ce871e9ecf86dd69d23) Refactor SQLite backup to use VACUUM INTO query - [`717ebfb`](https://github.com/dani-garcia/vaultwarden/commit/717ebfbf89731904f128a03dde95c11c7f41dae0) Fix VACUUM INTO query error handling ### 📊 Changes **1 file changed** (+7 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/db/mod.rs` (+7 -11) </details> ### 📄 Description https://github.com/dani-garcia/vaultwarden/pull/6279 introduced several great improvements, but replaced `VACUUM INTO` with `serialize_database_to_buffer()` which is less efficient and loads the whole DB into RAM. This may be contributing to an increase in OOM errors which I have noticed in small vaultwarden deployments with 256MB RAM. This PR reverts the `serialize_database_to_buffer()` change back into a `VACUUM INTO` query while keeping the other improvements from that PR. I also used `.bind::<Text, _>(&backup_file)` instead of the previous `format!("VACUUM INTO '{}'", backup_file)` to prevent theoretical SQL injection (even though path is trusted), let me know if you prefer the `format!` approach and I can switch it --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 12:37:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vaultwarden#8771