about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-23 09:36:54 +0000
committerEric Wong <e@80x24.org>2019-05-23 17:43:50 +0000
commit5cb7f35deae1de5f24525e595d2008d6c27cae69 (patch)
tree23c884be3d21c5378461b71cced80d8878da49db
parent7a097dce831a9ad3a99e50013138e57a0def514e (diff)
downloadpublic-inbox-5cb7f35deae1de5f24525e595d2008d6c27cae69.tar.gz
Running a full "public-inbox-index --reindex" in parallel
with "public-inbox-xcpdb" on the same inbox can still cause
problems, though.
-rw-r--r--lib/PublicInbox/Xapcmd.pm21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index 99f0e7c1..697221d9 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