]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei_search: make missing Xapian docs for kw lookups
authorEric Wong <e@80x24.org>
Wed, 14 Aug 2024 00:16:44 +0000 (00:16 +0000)
committerEric Wong <e@80x24.org>
Thu, 15 Aug 2024 08:29:05 +0000 (08:29 +0000)
Missing keyword entries should be non-fatal since Xapian
data is always less important than what's in git and SQLite.
As such, Xapian data has and remains written last, leaving
the possibility of documents being missing from Xapian but
present in SQLite and git.

This improves recovery dealing with badly interrupted or failed
imports due to bugs or hardware failures.

lib/PublicInbox/LeiSearch.pm

index 684668c50f0f6c3390c269fd63a42bdbed262cc1..4519306d824952bb3dc14458f4564e9135637818 100644 (file)
@@ -145,7 +145,15 @@ sub kw_changed {
        }
        if (!defined($cur_kw) && $@) {
                $docids = join(', num:', @$docids);
-               croak "E: num:$docids keyword lookup failure: $@";
+               # this may happen if a previous import was incomplete since
+               # we commit changes to Xapian last
+               if (ref($@) =~ /::DocNotFoundError\b/) {
+                       warn <<EOM;
+W: num:$docids keyword lookup failure, assuming no keywords
+EOM
+               } else {
+                       croak "E: num:$docids keyword lookup failure: $@";
+               }
        }
        # RFC 5550 sec 5.9 on the $Forwarded keyword states:
        # "Once set, the flag SHOULD NOT be cleared"