From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei: sqlite: do not forcibly enable WAL
Date: Thu, 16 Sep 2021 15:04:28 +0400 [thread overview]
Message-ID: <20210916110428.19614-1-e@80x24.org> (raw)
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
};
}
next reply other threads:[~2021-09-16 11:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 11:04 Eric Wong [this message]
2021-09-17 2:16 ` [PATCH] lei: sqlite: do not forcibly enable WAL Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210916110428.19614-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).