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-ASN: 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 AE7AA1F8C8 for ; Thu, 16 Sep 2021 11:04:28 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei: sqlite: do not forcibly enable WAL Date: Thu, 16 Sep 2021 15:04:28 +0400 Message-Id: <20210916110428.19614-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: I'm not sure why and I can no longer reproduce it; but I've triggered a SIGBUS in the lei/store inside the WAL commit code while writing to mail_sync.sqlite3 on my Debian (oldstable) buster system. It could be a problem with my ancient SSD, improper use on our end, a bug fixed in a newer SQLite version, etc.. In any case, lets minimize the risk and keep using TRUNCATE like we do with the time-tested public-inbox-* stuff, but respect WAL if a user wants to set it themselves. --- lib/PublicInbox/LeiMailSync.pm | 5 ++++- lib/PublicInbox/LeiSavedSearch.pm | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm index 5a10c127..dc4395f0 100644 --- a/lib/PublicInbox/LeiMailSync.pm +++ b/lib/PublicInbox/LeiMailSync.pm @@ -21,8 +21,11 @@ sub dbh_new { sqlite_use_immediate_transaction => 1, }); # no sqlite_unicode, here, all strings are binary + # 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) if $rw; - $dbh->do('PRAGMA journal_mode = WAL') if $creat; $dbh->do('PRAGMA case_sensitive_like = ON'); $dbh; } diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm index 96ff816e..8fcfa752 100644 --- a/lib/PublicInbox/LeiSavedSearch.pm +++ b/lib/PublicInbox/LeiSavedSearch.pm @@ -229,10 +229,7 @@ sub prepare_dedupe { my $oidx = PublicInbox::OverIdx->new($self->{-ovf}); $oidx->{-no_fsync} = 1; $oidx->dbh; - if ($creat) { - $oidx->{dbh}->do('PRAGMA journal_mode = WAL'); - $oidx->eidx_prep; # for xref3 - } + $oidx->eidx_prep if $creat; # for xref3 $oidx }; }