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-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 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 338411F915 for ; Fri, 24 Jul 2020 05:56:09 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 11/20] v2writable: get rid of {reindex_pipe} field Date: Fri, 24 Jul 2020 05:55:57 +0000 Message-Id: <20200724055606.27332-12-e@yhbt.net> In-Reply-To: <20200724055606.27332-1-e@yhbt.net> References: <20200724055606.27332-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Since normal per-epoch indexing no longer holds a "git log" process open, we don't need to worry about not sharing the pipe with forked shards when we restart the indexer. While we're in the area, better describe what `unindex' does, since it's a rarely-used but necessary code path. --- lib/PublicInbox/V2Writable.pm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index a85f9e1f8..c59ead393 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -848,8 +848,6 @@ sub content_exists ($$$) { sub atfork_child { my ($self) = @_; - my $fh = delete $self->{reindex_pipe}; - close $fh if $fh; if (my $shards = $self->{idx_shards}) { $_->atfork_child foreach @$shards; } @@ -1081,7 +1079,6 @@ sub sync_prepare ($$$) { my $reindex_heads = last_commits($self, $epoch_max) if $sync->{reindex}; for (my $i = $epoch_max; $i >= 0; $i--) { - die 'BUG: already indexing!' if $self->{reindex_pipe}; my $git_dir = git_dir_n($self, $i); -d $git_dir or next; # missing epochs are fine my $git = PublicInbox::Git->new($git_dir); @@ -1161,6 +1158,8 @@ sub unindex_oid ($$;$) { } } +# this is rare, it only happens when we get discontiguous history in +# a mirror because the source used -purge or -edit sub unindex ($$$$) { my ($self, $sync, $git, $unindex_range) = @_; my $unindexed = $self->{unindexed} ||= {}; # $mid0 => $num @@ -1168,12 +1167,11 @@ sub unindex ($$$$) { # order does not matter, here: my @cmd = qw(log --raw -r --no-notes --no-color --no-abbrev --no-renames); - my $fh = $self->{reindex_pipe} = $git->popen(@cmd, $unindex_range); + my $fh = $git->popen(@cmd, $unindex_range); while (<$fh>) { /\A:\d{6} 100644 $OID ($OID) [AM]\tm$/o or next; unindex_oid($self, $1, $unindexed); } - delete $self->{reindex_pipe}; close $fh or die "git log failed: \$?=$?"; return unless $sync->{-opt}->{prune}; @@ -1203,10 +1201,9 @@ sub index_epoch ($$$) { my ($self, $sync, $i) = @_; my $git_dir = git_dir_n($self, $i); - die 'BUG: already reindexing!' if $self->{reindex_pipe}; -d $git_dir or return; # missing epochs are fine my $git = PublicInbox::Git->new($git_dir); - if (my $unindex_range = delete $sync->{unindex_range}->{$i}) { + if (my $unindex_range = delete $sync->{unindex_range}->{$i}) { # rare unindex($self, $sync, $git, $unindex_range); } defined(my $stk = $sync->{stacks}->[$i]) or return;