From c1503b56aa1e6e61ccb30e129a823fd2a03d614d Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 1 May 2026 19:31:07 +0200 Subject: [PATCH] sgx/firefly: disable btrfs CoW on Firefly III sqlite directory Random-write SQLite traffic fragments CoW filesystems quickly. The `h` tmpfiles directive sets +C on the database directory; new SQLite files (WAL, SHM, recreated main DB) inherit no-CoW automatically. No-op on non-btrfs filesystems. Migration of existing files must be done manually with checkpoint-first: systemctl stop phpfpm-firefly-iii.service sqlite3 .../database.sqlite 'PRAGMA wal_checkpoint(TRUNCATE);' # then recreate main file inside the +C dir systemctl start phpfpm-firefly-iii.service Skipping the wal_checkpoint and naively deleting .sqlite-wal will lose all writes that haven't been checkpointed (PHP-FPM SIGTERM does not trigger a checkpoint). Co-Authored-By: Claude Opus 4.7 (1M context) --- systems/x86_64-linux/sgx/firefly.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/systems/x86_64-linux/sgx/firefly.nix b/systems/x86_64-linux/sgx/firefly.nix index 9eb7000..7b03607 100644 --- a/systems/x86_64-linux/sgx/firefly.nix +++ b/systems/x86_64-linux/sgx/firefly.nix @@ -53,6 +53,12 @@ in "d ${inbox} 0700 firefly-iii-data-importer nginx -" "d ${importerHome}/.aqbanking/imexporters/csv/profiles 0700 firefly-iii-data-importer nginx -" "L+ ${importerHome}/.aqbanking/imexporters/csv/profiles/firefly.conf - - - - ${fireflyCsvProfile}" + # Disable btrfs CoW on Firefly's SQLite directory — random-write + # SQLite traffic fragments CoW filesystems quickly. New files in + # this dir inherit the +C attribute. Existing database.sqlite, + # -wal, -shm need a one-time recreate to apply (use sqlite3 .backup + # into a fresh +C file). No-op on non-btrfs filesystems. + "h /var/lib/firefly-iii/storage/database - - - - +C" ]; services.firefly-sparda-fetch = {