]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imaptracker: preserve WAL journal_mode if set by user
authorEric Wong <e@yhbt.net>
Thu, 27 Aug 2020 12:17:00 +0000 (12:17 +0000)
committerEric Wong <e@yhbt.net>
Thu, 27 Aug 2020 22:33:43 +0000 (22:33 +0000)
It's no problem for most users to enable WAL, here, since
there's only a single process doing both reading and writing
(unlike the read-only daemons).  However, WAL doesn't work on
network filesystems, so it can't be enabled by default.

lib/PublicInbox/IMAPTracker.pm

index 102a74ce66b8ec0c1ba52be5200ee37d38dd08de..92f21584842d97d2d6d1d3747596e251ad8719d6 100644 (file)
@@ -29,7 +29,12 @@ sub dbh_new ($) {
                sqlite_use_immediate_transaction => 1,
        });
        $dbh->{sqlite_unicode} = 1;
-       $dbh->do('PRAGMA journal_mode = TRUNCATE');
+
+       # TRUNCATE reduces I/O compared to the default (DELETE).
+       # Allow and preserve user-overridden WAL, but don't force it.
+       my $jm = $dbh->selectrow_array('PRAGMA journal_mode');
+       $dbh->do('PRAGMA journal_mode = TRUNCATE') if $jm ne 'wal';
+
        create_tables($dbh);
        $dbh;
 }