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,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF 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 0BCAC1F51E for ; Fri, 30 Sep 2022 17:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1664558435; bh=ViAm+13I2uC2efCwhmCG06iybFQzrRpOYcbDhCfFGWs=; h=Date:From:To:Subject:References:In-Reply-To:From; b=awmNhABmr9a5A0uq6akVOYLH8/wNLVc1wnTsUfwjMh59ekJgLMWPVV4B9M326nERG mlroHnfzRpB2DZEEk4q/++8bTCeZRTJmGxheogH3UWHxjh37qR+HYJORlIIewBT1Dw 5m6sH+628cQu3ZR+hJ1nW0gzqp+h+dvED6ESWqeM= Date: Fri, 30 Sep 2022 17:20:34 +0000 From: Eric Wong To: meta@public-inbox.org Subject: SQLite <3.8.3 was broken on fork (was: fixes noticed while diagnosing t/lei-up.t) Message-ID: <20220930172034.GA24156@dcvr> References: <20220930092140.3894047-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220930092140.3894047-1-e@80x24.org> List-Id: Eric Wong 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";