]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: fix parallel termination
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sun, 1 Apr 2018 23:23:07 +0000 (23:23 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sun, 1 Apr 2018 23:25:08 +0000 (23:25 +0000)
I was too aggressively disabling parallelization to speed up
the test suite and broke this :x  Re-enable parallelization
for the v2reindex test so we can catch it later.

lib/PublicInbox/V2Writable.pm
t/v2reindex.t

index c8869bda3cf669b1de9428a570ce6ea0c5f6e2f0..51723e55ffb44662087f349a41a69a30fb36c5c1 100644 (file)
@@ -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;
index b9540e4abce4e3087549da720077d68644ef68b4..bf44fa0ad7bc291766b7bf1f9f53a4c9a2d6bb98 100644 (file)
@@ -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");