]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: avoid holding Xapian lock in cat-file
authorEric Wong <e@80x24.org>
Tue, 9 Aug 2016 00:41:37 +0000 (00:41 +0000)
committerEric Wong <e@80x24.org>
Tue, 9 Aug 2016 00:42:19 +0000 (00:42 +0000)
We must ensure cat-file process is launched before Xapian
grabs lock, too.  Our use of "git cat-file --batch" has
the same problem as "git log" did, (which was fixed in
commit 3713c727cda431a0dc2865a7878c13ecf9f21851)
"searchidx: release Xapian FDs before spawning git log"

lib/PublicInbox/Git.pm
lib/PublicInbox/SearchIdx.pm

index f47bc439080749c25100aca9cb1bb0f32b2d7c13..59c274702174f9e165ba30f99b4ed0136b04f67f 100644 (file)
@@ -39,7 +39,7 @@ sub _bidi_pipe {
 sub cat_file {
        my ($self, $obj, $ref) = @_;
 
-       $self->_bidi_pipe(qw(--batch in out pid));
+       batch_prepare($self);
        $self->{out}->print($obj, "\n") or fail($self, "write error: $!");
 
        my $in = $self->{in};
@@ -89,6 +89,8 @@ sub cat_file {
        $rv;
 }
 
+sub batch_prepare ($) { _bidi_pipe($_[0], qw(--batch in out pid)) }
+
 sub check {
        my ($self, $obj) = @_;
        $self->_bidi_pipe(qw(--batch-check in_c out_c pid_c));
index 6efc1f3fb937ebb17726cdbddbd3defd77c85e4b..0582526e8b1c5b0f0866b39911e1a94d9a3507dc 100644 (file)
@@ -390,6 +390,7 @@ sub _index_sync {
        my $tip = $opts->{ref} || 'HEAD';
        my $reindex = $opts->{reindex};
        my ($mkey, $last_commit, $lx, $xlog);
+       $self->{git}->batch_prepare;
        my $xdb = _xdb_acquire($self);
        $xdb->begin_transaction;
        do {