about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdxShard.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-15 02:02:16 +0000
committerEric Wong <e@80x24.org>2020-12-17 19:12:53 +0000
commit7281c5c492f9d6bbd585da9f061d19819d952352 (patch)
tree947228cf3f08bc6ae8874d99936fcef457096282 /lib/PublicInbox/SearchIdxShard.pm
parentd26c2837f479b41182946a6540aad95d34b2b594 (diff)
downloadpublic-inbox-7281c5c492f9d6bbd585da9f061d19819d952352.tar.gz
--reindex allows us to catch missed and stale messages due to
-extindex vs -index races prior to commit 02b2fcc46f364b51
("extsearchidx: enforce -index before -extindex").

We'll also rely on reindex to internally deal with v1/v2 inbox
removals and partial-unindexing of messages which are only
removed from one inbox out of many.

This reindex design is completely different than how normal
v1/v2 inbox reindex operates due to extindex having multiple
histories to work with.  Instead of scanning git history, this
relies exclusively on comparing over.sqlite3 contents between
the v1/v2 inboxes and the extindex.

Changes to Xapian behavior also get picked up, now.  Xapian indexing
is handled by workers with minimal IPC to the parent process.
This results in more read I/O but fewer writes when dealing
with cross-posted messages.

Changes to $smsg->populate and --rethread still need further
work.
Diffstat (limited to 'lib/PublicInbox/SearchIdxShard.pm')
-rw-r--r--lib/PublicInbox/SearchIdxShard.pm11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm
index 579ed196..b6eef6bd 100644
--- a/lib/PublicInbox/SearchIdxShard.pm
+++ b/lib/PublicInbox/SearchIdxShard.pm
@@ -94,6 +94,8 @@ sub shard_worker_loop ($$$$$) {
                         my $over_fn = $1;
                         $over_fn =~ tr/\0/\n/;
                         $self->over_check(PublicInbox::Over->new($over_fn));
+                } elsif ($line =~ /\AE ([0-9]+)\n/) {
+                        $self->reindex_docid($1 + 0);
                 } else {
                         chomp $line;
                         my $eidx_key;
@@ -223,4 +225,13 @@ sub shard_over_check {
         }
 }
 
+sub shard_reindex_docid {
+        my ($self, $docid) = @_;
+        if (my $w = $self->{w}) {
+                print $w "E $docid\n" or die "failed to write to shard: $!";
+        } else {
+                $self->reindex_docid($docid);
+        }
+}
+
 1;