From d463ecedb2030e53eb92befe8f642d9e244c9eae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Nov 2020 10:56:55 +0000 Subject: v2writable: less expensive checkpoint for extindex Since extindex holds no locks on parallel inbox writers, we can simply use "barrier" IPC shard commands to checkpoint and avoid respawning shard or git processes. --- lib/PublicInbox/V2Writable.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 0364857f..224675ab 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -620,13 +620,13 @@ sub checkpoint ($;$) { # Now deal with Xapian if ($wait) { - my $barrier = $self->barrier_init(scalar @$shards); + my $barrier = barrier_init($self, scalar @$shards); # each shard needs to issue a barrier command $_->shard_barrier for @$shards; # wait for each Xapian shard - $self->barrier_wait($barrier); + barrier_wait($self, $barrier); } else { $_->shard_commit for @$shards; } @@ -860,11 +860,16 @@ sub atfork_child { sub reindex_checkpoint ($$) { my ($self, $sync) = @_; - $self->git->cleanup; # *async_wait + $self->git->async_wait_all; ${$sync->{need_checkpoint}} = 0; my $mm_tmp = $sync->{mm_tmp}; $mm_tmp->atfork_prepare if $mm_tmp; - $self->done; # release lock + die 'BUG: {im} during reindex' if $self->{im}; + if ($self->{ibx_map}) { + checkpoint($self, 1); # no need to release lock on pure index + } else { + $self->done; # release lock + } if (my $pr = $sync->{-opt}->{-progress}) { $pr->(sprintf($sync->{-regen_fmt}, ${$sync->{nr}})); -- cgit v1.2.3-24-ge0c7