From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 482681F670 for ; Thu, 27 Aug 2020 12:17:07 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/8] imaptracker: preserve WAL journal_mode if set by user Date: Thu, 27 Aug 2020 12:17:00 +0000 Message-Id: <20200827121706.4545-3-e@yhbt.net> In-Reply-To: <20200827121706.4545-1-e@yhbt.net> References: <20200827121706.4545-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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; }