From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: SQLite <3.8.3 was broken on fork (was: fixes noticed while diagnosing t/lei-up.t)
Date: Fri, 30 Sep 2022 17:20:34 +0000 [thread overview]
Message-ID: <20220930172034.GA24156@dcvr> (raw)
In-Reply-To: <20220930092140.3894047-1-e@80x24.org>
Eric Wong <e@80x24.org> wrote:
> I'm still trying to figure out why OverIdx->adj_counter (via
> next_tid) in the LeiSavedSearch dedupe check occasionally fails
> under CentOS 7.x (but not other systems).
CentOS 7.x ships SQLite 3.7.17, and SQLite prior to 3.8.3 (2014-02-03)
didn't reset its PRNG for generating temporary filenames upon fork.
I can't find a way reset that PRNG via DBD::SQLite, either...
One possible nasty thing I could do is reset TMPDIR upon fork,
but that may leave bugs lingering, too :<
Here's the debugging patch I used to strace what was going on:
(I may just make lei_ok bail out on error...)
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index e7c96e14..e1af910c 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -51,10 +51,22 @@ SELECT val FROM counter WHERE key = ? LIMIT 1
sub adj_counter ($$$) {
my ($self, $key, $op) = @_;
my $dbh = $self->{dbh};
+use PublicInbox::Spawn qw(spawn);
+my $trace = "/tmp/$$.strace";
+open my $err, '>>', $trace;
+my $pid = spawn([qw(strace -f -s4096 -v -p), $$], undef, { 2 => $err });
+select undef, undef, undef, 0.1;
+
my $sth = $dbh->prepare_cached(<<"");
UPDATE counter SET val = val $op 1 WHERE key = ?
- $sth->execute($key);
+ eval { $sth->execute($key) };
+my $err = $@;
+syswrite(STDERR, "$$ $err\n") if $err;
+kill('TERM', $pid);
+waitpid($pid, 0);
+die $err if $err;
+#unlink($trace);
get_counter($dbh, $key);
}
diff --git a/t/lei-up.t b/t/lei-up.t
index baed6507..9c65a243 100644
--- a/t/lei-up.t
+++ b/t/lei-up.t
@@ -27,7 +27,7 @@ test_lei(sub {
lei_ok qw(ls-search);
$s = eml_load('t/utf8.eml')->as_string;
lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
- lei_ok qw(up --all=local);
+ lei_ok qw(up --all=local) or xbail "lei up --all=local failed $?";
gunzip("$home/a.mbox.gz" => \$uc, MultiStream => 1) or
xbail "gunzip $GunzipError";
prev parent reply other threads:[~2022-09-30 17:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 9:21 [PATCH 0/4] fixes noticed while diagnosing t/lei-up.t Eric Wong
2022-09-30 9:21 ` [PATCH 1/4] tests: favor 3 argument `open' with interopolation Eric Wong
2022-09-30 9:21 ` [PATCH 2/4] t/lei-up: improve diagnostics for this test Eric Wong
2022-09-30 9:21 ` [PATCH 3/4] lei_to_mail: propagate errors to script/lei Eric Wong
2022-09-30 9:21 ` [PATCH 4/4] t/altid_v2: improve test style Eric Wong
2022-09-30 17:20 ` Eric Wong [this message]
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=20220930172034.GA24156@dcvr \
--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.
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).