]> 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 0a91a132bd93f9b373e400ae0d5a6c2afed06281..553dd839f39a9a56227e8a092d55e791ca54b2e0 100644 (file)
@@ -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) = @_;
@@ -679,8 +682,8 @@ sub done {
                        $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;
@@ -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;