]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
v2writable: fix parallel termination
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index c4368cccc8502616ab8c4c536720d7c17106f596..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;
@@ -634,15 +638,19 @@ sub reindex {
                        -d $git->{git_dir} or next; # missing parts are fine
                        chomp($tip = $git->qx('rev-parse', $head)) unless $tip;
                        my $h = $cur == $max_git ? $tip : $head;
-                       my @count = ('rev-list', '--count', $h, '--', 'm');
-                       $regen_max += $git->qx(@count);
+
+                       # can't use 'rev-list --count' if we use --diff-filter
+                       my $fh = $git->popen(qw(log --pretty=tformat:%h
+                                       --no-notes --no-color --no-renames
+                                       --diff-filter=AM), $h, '--', 'm');
+                       ++$regen_max while <$fh>;
                }
                die "No messages found in $pfx/*.git, bug?\n" unless $regen_max;
                $regen = \$regen_max;
        }
        my $D = {};
        my @cmd = qw(log --raw -r --pretty=tformat:%h
-                       --no-notes --no-color --no-abbrev);
+                       --no-notes --no-color --no-abbrev --no-renames);
 
        # if we are regenerating, we must not use a newer tip commit than what
        # the regeneration counter used:
@@ -663,7 +671,7 @@ sub reindex {
                        } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o) {
                                $self->reindex_oid($mm_tmp, $D, $git, $1,
                                                $regen);
-                       } elsif (m!\A:\d{6} 100644 $x40 ($x40) [AM]\t_/D$!o) {
+                       } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\td$/o) {
                                $self->mark_deleted($D, $git, $1);
                        }
                }