* [PATCH] searchidx: avoid holding Xapian lock in cat-file
@ 2016-08-09 0:41 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-08-09 0:41 UTC (permalink / raw)
To: spew
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 | 4 +++-
lib/PublicInbox/SearchIdx.pm | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index f47bc43..59c2747 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -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));
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 6efc1f3..0582526 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -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 {
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-09 0:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-09 0:41 [PATCH] searchidx: avoid holding Xapian lock in cat-file Eric Wong
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).