]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
watch: avoid unnecessary spawning on spam removals
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index d99e476aa9b3ba2319231bee6691b436aeaeec3c..553dd839f39a9a56227e8a092d55e791ca54b2e0 100644 (file)
@@ -630,12 +630,12 @@ sub checkpoint ($;$) {
                        my $barrier = $self->barrier_init(scalar @$shards);
 
                        # each shard needs to issue a barrier command
-                       $_->remote_barrier for @$shards;
+                       $_->shard_barrier for @$shards;
 
                        # wait for each Xapian shard
                        $self->barrier_wait($barrier);
                } else {
-                       $_->remote_commit for @$shards;
+                       $_->shard_commit for @$shards;
                }
 
                # last_commit is special, don't commit these until
@@ -655,6 +655,9 @@ sub checkpoint ($;$) {
 # public
 sub barrier { checkpoint($_[0], 1) };
 
+# true if locked and active
+sub active { !!$_[0]->{im} }
+
 # public
 sub done {
        my ($self) = @_;
@@ -675,12 +678,12 @@ sub done {
        my $shards = delete $self->{idx_shards};
        if ($shards) {
                for (@$shards) {
-                       eval { $_->remote_close };
+                       eval { $_->shard_close };
                        $err .= "shard close: $@\n" if $@;
                }
        }
-       eval { $self->{over}->disconnect };
-       $err .= "over disconnect: $@\n" if $@;
+       eval { $self->{over}->dbh_close };
+       $err .= "over close: $@\n" if $@;
        delete $self->{bnote};
        my $nbytes = $self->{total_bytes};
        $self->{total_bytes} = 0;
@@ -995,7 +998,7 @@ sub log_range ($$$$$) {
        my $opt = $sync->{-opt};
        my $pr = $opt->{-progress} if (($opt->{verbose} || 0) > 1);
        my $cur = $sync->{ranges}->[$i] or do {
-               $pr->("$i.git indexing all of $tip") if $pr;
+               $pr->("$i.git indexing all of $tip\n") if $pr;
                return $tip; # all of it
        };
 
@@ -1107,7 +1110,7 @@ sub unindex_oid_remote ($$$) {
        my @removed = $self->{over}->remove_oid($oid, $mid);
        for my $num (@removed) {
                my $idx = idx_shard($self, $num % $self->{shards});
-               $idx->remote_remove($oid, $num);
+               $idx->shard_remove($oid, $num);
        }
 }
 
@@ -1264,8 +1267,11 @@ sub xapian_only {
                $sync->{art_end} = $art_end;
                if ($seq || !$self->{parallel}) {
                        my $shard_end = $self->{shards} - 1;
-                       for (0..$shard_end) {
-                               index_xap_step($self, $sync, $art_beg + $_)
+                       for my $i (0..$shard_end) {
+                               index_xap_step($self, $sync, $art_beg + $i);
+                               if ($i != $shard_end) {
+                                       reindex_checkpoint($self, $sync);
+                               }
                        }
                } else { # parallel (maybe)
                        index_xap_step($self, $sync, $art_beg, 1);
@@ -1337,6 +1343,18 @@ sub index_sync {
                xapian_only($self, $opt, $sync, $art_beg);
        }
 
+       # --reindex on the command-line
+       if ($opt->{reindex} && !ref($opt->{reindex}) && $idxlevel ne 'basic') {
+               $self->lock_acquire;
+               my $s0 = PublicInbox::SearchIdx->new($self->{ibx}, 0, 0);
+               if (my $xdb = $s0->idx_acquire) {
+                       my $n = $xdb->get_metadata('has_threadid');
+                       $xdb->set_metadata('has_threadid', '1') if $n ne '1';
+               }
+               $s0->idx_release;
+               $self->lock_release;
+       }
+
        # reindex does not pick up new changes, so we rerun w/o it:
        if ($opt->{reindex}) {
                my %again = %$opt;