about summary refs log tree commit homepage
path: root/lib/PublicInbox/Msgmap.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-18 06:36:32 +0000
committerEric Wong <e@yhbt.net>2020-07-18 23:58:08 +0000
commit0ad076b1943bf7c65868d1db3cef4bd0ea1ef49a (patch)
treea34e119790fd3d9015f2fbd58d865ebe1769f5e3 /lib/PublicInbox/Msgmap.pm
parent340652d9833d9b7de4724a721e7014bfed262ccf (diff)
downloadpublic-inbox-0ad076b1943bf7c65868d1db3cef4bd0ea1ef49a.tar.gz
Noticed while reindexing a largish v2 inbox in parallel on an
SSD which required checkpointing and respawning shard workers.

Fixes: f06e84220e5566e7 ("over+msgmap: do not store filename after DBI->connect")
Diffstat (limited to 'lib/PublicInbox/Msgmap.pm')
-rw-r--r--lib/PublicInbox/Msgmap.pm17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index 38ec7858..9d2ef0dc 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -238,22 +238,21 @@ sub DESTROY {
 
 sub atfork_parent {
         my ($self) = @_;
-        $self->{pid} or die "not a temporary clone\n";
-        my $dbh = $self->{dbh} and die "tmp_clone dbh not prepared for parent";
-        $self->{filename} = $dbh->sqlite_db_filename;
-        $dbh = $self->{dbh} = PublicInbox::Over::dbh_new($self, 1);
+        $self->{pid} or die 'BUG: not a temporary clone';
+        $self->{dbh} and die 'BUG: tmp_clone dbh not prepared for parent';
+        defined($self->{filename}) or die 'BUG: {filename} not defined';
+        my $dbh = $self->{dbh} = PublicInbox::Over::dbh_new($self, 1);
         $dbh->do('PRAGMA synchronous = OFF');
 }
 
 sub atfork_prepare {
         my ($self) = @_;
-        $self->{pid} or die "not a temporary clone\n";
-        $self->{pid} == $$ or
-                die "BUG: atfork_prepare not called from $self->{pid}\n";
-        my $dbh = $self->{dbh} or die "temporary clone not open\n";
+        my $pid = $self->{pid} or die 'BUG: not a temporary clone';
+        $pid == $$ or die "BUG: atfork_prepare not called by $pid";
+        my $dbh = $self->{dbh} or die 'BUG: temporary clone not open';
 
         # must clobber prepared statements
-        %$self = (filename => $dbh->sqlite_db_filename, pid => $$);
+        %$self = (filename => $dbh->sqlite_db_filename, pid => $pid);
 }
 
 sub skip_artnum {