]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2/ui: retry DB reopens in a few more places
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 22 Feb 2018 21:17:53 +0000 (21:17 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Wed, 28 Feb 2018 18:45:35 +0000 (18:45 +0000)
Relying more on Xapian requires retrying reopens in more
places to ensure it does not fall down and show errors to
the user.

lib/PublicInbox/Inbox.pm
lib/PublicInbox/Search.pm

index f000a950e48b2754a54fb8477ace9de34c106712..54a6eb32e184f71b8350454292dc4dbf06534314 100644 (file)
@@ -254,9 +254,11 @@ sub msg_by_mid ($$;$) {
        my ($self, $mid, $ref) = @_;
        my $srch = search($self) or
                        return msg_by_path($self, mid2path($mid), $ref);
-       my $smsg = $srch->lookup_skeleton($mid) or return;
-       $smsg->load_expand;
-       msg_by_smsg($self, $smsg, $ref);
+       my $smsg;
+       $srch->retry_reopen(sub {
+               $smsg = $srch->lookup_skeleton($mid) and $smsg->load_expand;
+       });
+       $smsg ? msg_by_smsg($self, $smsg, $ref) : undef;
 }
 
 1;
index b20b2ccd3e39f3b0ede3425c1b46c55f03654674..1df87d0ef6ce89bbb1e72223e107e87b6e53b043 100644 (file)
@@ -185,7 +185,7 @@ sub query {
 
 sub get_thread {
        my ($self, $mid, $opts) = @_;
-       my $smsg = eval { $self->lookup_skeleton($mid) };
+       my $smsg = retry_reopen($self, sub { lookup_skeleton($self, $mid) });
 
        return { total => 0, msgs => [] } unless $smsg;
        my $qtid = Search::Xapian::Query->new('G' . $smsg->thread_id);
@@ -216,6 +216,7 @@ sub retry_reopen {
                if (ref($@) eq 'Search::Xapian::DatabaseModifiedError') {
                        reopen($self);
                } else {
+                       warn "ref: ", ref($@), "\n";
                        die;
                }
        }