user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 1/2] search: reopen and retry on updated databases
  2016-06-19 10:20  5% [PATCH 0/2] robustness improvements Eric Wong
@ 2016-06-19 10:20  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-06-19 10:20 UTC (permalink / raw)
  To: meta

This seems like a nasty thing which breaks downloads of
large mailboxes.
---
 lib/PublicInbox/Search.pm | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index d9fbc36..856c8c1 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -97,7 +97,7 @@ sub query {
 		$opts->{relevance} = 1 unless exists $opts->{relevance};
 	}
 
-	$self->do_enquire($query, $opts);
+	_do_enquire($self, $query, $opts);
 }
 
 sub get_thread {
@@ -111,10 +111,26 @@ sub get_thread {
 	my $query = Search::Xapian::Query->new(OP_OR, $qtid, $qsub);
 	$opts ||= {};
 	$opts->{limit} ||= 1000;
-	$self->do_enquire($query, $opts);
+	_do_enquire($self, $query, $opts);
 }
 
-sub do_enquire {
+sub _do_enquire {
+	my ($self, $query, $opts) = @_;
+	my $ret;
+	for (1..10) {
+		eval { $ret = _enquire_once($self, $query, $opts) };
+		return $ret unless $@;
+		# Exception: The revision being read has been discarded -
+		# you should call Xapian::Database::reopen()
+		if (index($@, 'Xapian::Database::reopen') >= 0) {
+			reopen($self);
+		} else {
+			die $@;
+		}
+	}
+}
+
+sub _enquire_once {
 	my ($self, $query, $opts) = @_;
 	my $enquire = $self->enquire;
 	if (defined $query) {
@@ -127,6 +143,8 @@ sub do_enquire {
         my $desc = !$opts->{asc};
 	if ($opts->{relevance}) {
 		$enquire->set_sort_by_relevance_then_value(TS, $desc);
+	} elsif ($opts->{num}) {
+		$enquire->set_sort_by_value(NUM, 0);
 	} else {
 		$enquire->set_sort_by_value_then_relevance(TS, $desc);
 	}
@@ -186,21 +204,12 @@ sub num_range_processor {
 # only used for NNTP server
 sub query_xover {
 	my ($self, $beg, $end, $offset) = @_;
-	my $enquire = $self->enquire;
 	my $qp = Search::Xapian::QueryParser->new;
 	$qp->set_database($self->{xdb});
 	$qp->add_valuerangeprocessor($self->num_range_processor);
 	my $query = $qp->parse_query("$beg..$end", QP_FLAGS);
-	$query = Search::Xapian::Query->new(OP_AND, $mail_query, $query);
-	$enquire->set_query($query);
-	$enquire->set_sort_by_value(NUM, 0);
-	my $limit = 200;
-	my $mset = $enquire->get_mset($offset, $limit);
-	my @msgs = map {
-		PublicInbox::SearchMsg->load_doc($_->get_document);
-	} $mset->items;
 
-	{ total => $mset->get_matches_estimated, msgs => \@msgs }
+	_do_enquire($self, $query, {num => 1, limit => 200, offset => $offset});
 }
 
 sub lookup_message {

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/2] robustness improvements
@ 2016-06-19 10:20  5% Eric Wong
  2016-06-19 10:20  7% ` [PATCH 1/2] search: reopen and retry on updated databases Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2016-06-19 10:20 UTC (permalink / raw)
  To: meta

Because I care about users downloading over 300 MB from
the all.mbox.gz endpoint over Tor or cloning nearly
800 MB over git.

It would be nice to be able to resume when a disconnect
does happen, however...

Eric Wong (2):
      search: reopen and retry on updated databases
      examples/*@.service: wait one day for graceful shutdown

 examples/public-inbox-httpd@.service |  2 +-
 examples/public-inbox-nntpd@.service |  2 +-
 lib/PublicInbox/Search.pm            | 35 ++++++++++++++++++++++-------------
 3 files changed, 24 insertions(+), 15 deletions(-)


^ permalink raw reply	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-06-19 10:20  5% [PATCH 0/2] robustness improvements Eric Wong
2016-06-19 10:20  7% ` [PATCH 1/2] search: reopen and retry on updated databases Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).