about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-28 17:37:00 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-28 23:06:20 +0000
commit79e6a74dbc6274efe6a7150f97bdac3043de42cf (patch)
tree233013823d9964cac93a3c594ca2540d5fa23347 /lib
parent4ac55dde4d10887a7ad9c325924d322491bd61d1 (diff)
downloadpublic-inbox-79e6a74dbc6274efe6a7150f97bdac3043de42cf.tar.gz
I added these while chasing down the DatabaseCorruptError
exceptions which turned out to be caused by Xapian DB
modifications during iteration.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/SearchIdxSkeleton.pm8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/PublicInbox/SearchIdxSkeleton.pm b/lib/PublicInbox/SearchIdxSkeleton.pm
index 0016f89a..aa2713f1 100644
--- a/lib/PublicInbox/SearchIdxSkeleton.pm
+++ b/lib/PublicInbox/SearchIdxSkeleton.pm
@@ -42,7 +42,6 @@ sub new {
 sub skeleton_worker_loop {
         my ($self, $r) = @_;
         $0 = 'pi-v2-skeleton';
-        my $msg;
         my $xdb = $self->_xdb_acquire;
         $xdb->begin_transaction;
         my $txn = 1;
@@ -54,9 +53,12 @@ sub skeleton_worker_loop {
                         $self->_xdb_release;
                         $xdb = $txn = undef;
                 } else {
-                        read($r, $msg, $line) or die "read failed: $!\n";
+                        my $len = int($line);
+                        my $n = read($r, my $msg, $len) or die "read: $!\n";
+                        $n == $len or die "short read: $n != $len\n";
                         $msg = thaw($msg); # should raise on error
                         defined $msg or die "failed to thaw buffer\n";
+                        $xdb ||= $self->_xdb_acquire;
                         if (!$txn) {
                                 $xdb->begin_transaction;
                                 $txn = 1;
@@ -65,6 +67,8 @@ sub skeleton_worker_loop {
                         warn "failed to index message <$msg->[-1]>: $@\n" if $@;
                 }
         }
+        die "xdb not released\n" if $xdb;
+        die "in transaction\n" if $txn;
 }
 
 # called by a partition worker