diff options
author | Eric Wong <e@80x24.org> | 2016-12-10 23:35:43 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-12-10 23:44:10 +0000 |
commit | 53e8cfbe4e06e5ae6ad61fb7e9bd45804c253a72 (patch) | |
tree | d5f6566a46d847e9f807450fbe10ef1b819bb29e /lib/PublicInbox/Search.pm | |
parent | 71d0581a309ca83cf3be538141435111db8ed290 (diff) | |
download | public-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/Search.pm')
-rw-r--r-- | lib/PublicInbox/Search.pm | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 5e6bfc68..24cb2667 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -166,22 +166,27 @@ sub get_thread { _do_enquire($self, $qtid, $opts); } -sub _do_enquire { - my ($self, $query, $opts) = @_; +sub retry_reopen { + my ($self, $cb) = @_; my $ret; for (1..10) { - eval { $ret = _enquire_once($self, $query, $opts) }; + eval { $ret = $cb->() }; return $ret unless $@; # Exception: The revision being read has been discarded - # you should call Xapian::Database::reopen() - if (index($@, 'Xapian::Database::reopen') >= 0) { + if (ref($@) eq 'Search::Xapian::DatabaseModifiedError') { reopen($self); } else { - die $@; + die; } } } +sub _do_enquire { + my ($self, $query, $opts) = @_; + retry_reopen($self, sub { _enquire_once($self, $query, $opts) }); +} + sub _enquire_once { my ($self, $query, $opts) = @_; my $enquire = $self->enquire; |