]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: less expensive checkpoint for extindex
authorEric Wong <e@80x24.org>
Sat, 7 Nov 2020 10:56:55 +0000 (10:56 +0000)
committerEric Wong <e@80x24.org>
Sun, 8 Nov 2020 10:18:18 +0000 (10:18 +0000)
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

index 0364857fa6e75891a979b73c2f938dd7e2314881..224675aba5ecc9820f680b903548cea17637bd75 100644 (file)
@@ -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}}));