about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/V2Writable.pm10
-rw-r--r--t/v2reindex.t3
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index c8869bda..51723e55 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -204,9 +204,13 @@ sub idx_init {
 
                 # need to create all parts before initializing msgmap FD
                 my $max = $self->{partitions} - 1;
-                @{$self->{idx_parts}} = map {
-                        PublicInbox::SearchIdxPart->new($self, $_, $skel);
-                } (0..$max);
+
+                # idx_parts must be visible to all forked processes
+                my $idx = $self->{idx_parts} = [];
+                for my $i (0..$max) {
+                        push @$idx,
+                             PublicInbox::SearchIdxPart->new($self, $i, $skel);
+                }
 
                 # Now that all subprocesses are up, we can open the FD for SQLite:
                 $skel->_msgmap_init->{dbh}->begin_work;
diff --git a/t/v2reindex.t b/t/v2reindex.t
index b9540e4a..bf44fa0a 100644
--- a/t/v2reindex.t
+++ b/t/v2reindex.t
@@ -30,9 +30,8 @@ my $mime = PublicInbox::MIME->create(
         ],
         body => "hello world\n",
 );
-
+local $ENV{NPROC} = 2;
 my $im = PublicInbox::V2Writable->new($ibx, 1);
-$im->{parallel} = 0;
 foreach my $i (1..10) {
         $mime->header_set('Message-Id', "<$i\@example.com>");
         ok($im->add($mime), "message $i added");