From 1e3c53a422b8d23cff961e43f77ea0a835cdef78 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 27 Aug 2020 12:17:00 +0000 Subject: [PATCH] imaptracker: preserve WAL journal_mode if set by user 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/IMAPTracker.pm b/lib/PublicInbox/IMAPTracker.pm index 102a74ce..92f21584 100644 --- a/lib/PublicInbox/IMAPTracker.pm +++ b/lib/PublicInbox/IMAPTracker.pm @@ -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; } -- 2.44.0