user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] search: retry_reopen on first_smsg_by_mid
@ 2018-03-29 19:14 Eric Wong (Contractor, The Linux Foundation)
  0 siblings, 0 replies; only message in thread
From: Eric Wong (Contractor, The Linux Foundation) @ 2018-03-29 19:14 UTC (permalink / raw)
  To: meta

This was causing errors while attempting to load messages via
the WWW interface while mass-importing LKML.  While we're at it,
remove unnecessary eval from lookup_article.
---
 lib/PublicInbox/Search.pm | 46 ++++++++++++++++++++++------------------------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 6f5e062..5fc7682 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -348,36 +348,34 @@ sub query_ts {
 sub first_smsg_by_mid {
 	my ($self, $mid) = @_;
 	my $smsg;
-	each_smsg_by_mid($self, $mid, sub { $smsg = $_[0]; undef });
+	retry_reopen($self, sub {
+		each_smsg_by_mid($self, $mid, sub { $smsg = $_[0]; undef });
+	});
 	$smsg;
 }
 
 sub lookup_article {
 	my ($self, $num) = @_;
 	my $term = 'XNUM'.$num;
-	my $smsg;
-	eval {
-		retry_reopen($self, sub {
-			my $db = $self->{skel} || $self->{xdb};
-			my $head = $db->postlist_begin($term);
-			my $tail = $db->postlist_end($term);
-			return if $head->equal($tail);
-			my $doc_id = $head->get_docid;
-			return unless defined $doc_id;
-			$head->inc;
-			if ($head->nequal($tail)) {
-				my $loc= $self->{mainrepo} .
-					($self->{skel} ? 'skel' : 'xdb');
-				warn "article #$num is not unique in $loc\n";
-			}
-			# raises on error:
-			my $doc = $db->get_document($doc_id);
-			$smsg = PublicInbox::SearchMsg->wrap($doc);
-			$smsg->load_expand;
-			$smsg->{doc_id} = $doc_id;
-		});
-	};
-	$smsg;
+	my $db = $self->{skel} || $self->{xdb};
+	retry_reopen($self, sub {
+		my $head = $db->postlist_begin($term);
+		my $tail = $db->postlist_end($term);
+		return if $head->equal($tail);
+		my $doc_id = $head->get_docid;
+		return unless defined $doc_id;
+		$head->inc;
+		if ($head->nequal($tail)) {
+			my $loc= $self->{mainrepo} .
+				($self->{skel} ? 'skel' : 'xdb');
+			warn "article #$num is not unique in $loc\n";
+		}
+		# raises on error:
+		my $doc = $db->get_document($doc_id);
+		my $smsg = PublicInbox::SearchMsg->wrap($doc);
+		$smsg->{doc_id} = $doc_id;
+		$smsg->load_expand;
+	});
 }
 
 sub each_smsg_by_mid {
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-29 19:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29 19:14 [PATCH] search: retry_reopen on first_smsg_by_mid Eric Wong (Contractor, The Linux Foundation)

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).