about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-12-10 23:35:43 +0000
committerEric Wong <e@80x24.org>2016-12-10 23:44:10 +0000
commit53e8cfbe4e06e5ae6ad61fb7e9bd45804c253a72 (patch)
treed5f6566a46d847e9f807450fbe10ef1b819bb29e /lib/PublicInbox/View.pm
parent71d0581a309ca83cf3be538141435111db8ed290 (diff)
downloadpublic-inbox-53e8cfbe4e06e5ae6ad61fb7e9bd45804c253a72.tar.gz
In addition to needing to retry enquire queries, we also need
to protect document loading from the Xapian DB and retry on
modification, as it seems to throw the same errors.

Checking the $@ ref for Search::Xapian::DatabaseModifiedError
is actually in the test suite for both the XS and SWIG Xapian
bindings, so we should be good as far as forward/backwards
compatibility.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index ec5f7e0f..fa47a16a 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -327,8 +327,9 @@ sub stream_thread ($$) {
 sub thread_html {
         my ($ctx) = @_;
         my $mid = $ctx->{mid};
-        my $sres = $ctx->{srch}->get_thread($mid);
-        my $msgs = load_results($sres);
+        my $srch = $ctx->{srch};
+        my $sres = $srch->get_thread($mid);
+        my $msgs = load_results($srch, $sres);
         my $nr = $sres->{total};
         return missing_thread($ctx) if $nr == 0;
         my $skel = '<hr><pre>';
@@ -574,7 +575,8 @@ sub thread_skel {
         $ctx->{prev_attr} = '';
         $ctx->{prev_level} = 0;
         $ctx->{dst} = $dst;
-        walk_thread(thread_results(load_results($sres)), $ctx, *skel_dump);
+        $sres = load_results($srch, $sres);
+        walk_thread(thread_results($sres), $ctx, *skel_dump);
         $ctx->{parent_msg} = $parent;
 }
 
@@ -733,9 +735,9 @@ sub indent_for {
 }
 
 sub load_results {
-        my ($sres) = @_;
-
-        [ map { $_->ensure_metadata; $_ } @{delete $sres->{msgs}} ];
+        my ($srch, $sres) = @_;
+        my $msgs = delete $sres->{msgs};
+        $srch->retry_reopen(sub { [ map { $_->ensure_metadata; $_ } @$msgs ] });
 }
 
 sub msg_timestamp {
@@ -975,10 +977,11 @@ sub index_topics {
         my $opts = { offset => $off, limit => 200 };
 
         $ctx->{order} = [];
-        my $sres = $ctx->{srch}->query('', $opts);
+        my $srch = $ctx->{srch};
+        my $sres = $srch->query('', $opts);
         my $nr = scalar @{$sres->{msgs}};
         if ($nr) {
-                $sres = load_results($sres);
+                $sres = load_results($srch, $sres);
                 walk_thread(thread_results($sres), $ctx, *acc_topic);
         }
         $ctx->{-next_o} = $off+ $nr;