From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C8F1A205DA for ; Thu, 23 May 2019 09:37:10 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 16/26] xcpdb: cleanup error handling and diagnosis Date: Thu, 23 May 2019 09:36:54 +0000 Message-Id: <20190523093704.18367-17-e@80x24.org> In-Reply-To: <20190523093704.18367-1-e@80x24.org> References: <20190523093704.18367-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Running a full "public-inbox-index --reindex" in parallel with "public-inbox-xcpdb" on the same inbox can still cause problems, though. --- lib/PublicInbox/Xapcmd.pm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm index 99f0e7c..697221d 100644 --- a/lib/PublicInbox/Xapcmd.pm +++ b/lib/PublicInbox/Xapcmd.pm @@ -163,13 +163,16 @@ sub run { } sub cpdb_retryable ($$) { - my ($src, $err) = @_; - if (ref($err) eq 'Search::Xapian::DatabaseModifiedError') { - warn "$err, reopening and retrying\n"; + my ($src, $pfx) = @_; + if (ref($@) eq 'Search::Xapian::DatabaseModifiedError') { + warn "$pfx Xapian DB modified, reopening and retrying\n"; $src->reopen; return 1; } - die $err if $err; + if ($@) { + warn "$pfx E: ", ref($@), "\n"; + die; + } 0; } @@ -186,7 +189,8 @@ sub cpdb { my $creat = Search::Xapian::DB_CREATE(); my $dst = Search::Xapian::WritableDatabase->new($tmp, $creat); my ($it, $end); - my ($pfx, $nr, $tot, $fmt); # progress output + my $pfx = ''; + my ($nr, $tot, $fmt); # progress output do { eval { @@ -196,15 +200,15 @@ sub cpdb { $it = $src->postlist_begin(''); $end = $src->postlist_end(''); + $pfx = (split('/', $old))[-1].':'; if ($opt->{-progress}) { $nr = 0; - $pfx = (split('/', $old))[-1].':'; $tot = $src->get_doccount; $fmt = "$pfx % ".length($tot)."u/$tot\n"; warn "$pfx copying $tot documents\n"; } }; - } while (cpdb_retryable($src, $@)); + } while (cpdb_retryable($src, $pfx)); do { eval { @@ -223,12 +227,13 @@ sub cpdb { # the Perl APIs don't expose iterators for them # (and public-inbox does not use those features) }; - } while (cpdb_retryable($src, $@)); + } while (cpdb_retryable($src, $pfx)); warn(sprintf($fmt, $nr)) if $fmt; return unless $opt->{compact}; $src = $dst = undef; # flushes and closes + $pfx = undef unless $fmt; warn "$pfx compacting...\n" if $pfx; # this is probably the best place to do xapian-compact -- EW