From 7281c5c492f9d6bbd585da9f061d19819d952352 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 15 Dec 2020 02:02:16 +0000 Subject: extindex: preliminary --reindex support --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. --- lib/PublicInbox/SearchIdxShard.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/PublicInbox/SearchIdxShard.pm') 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; -- cgit v1.2.3-24-ge0c7