From: "Kyle J. McKay" <mackyle@gmail.com>
To: "Eric Wong" <normalperson@yhbt.net>, Mike <ipso@snappymail.ca>,
Minty <mintywalker@gmail.com>,
"Nico Schlömer" <nico.schloemer@gmail.com>,
"Valery Yundin" <yuvalery@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Git mailing list <git@vger.kernel.org>
Subject: Re: git svn import failure : write .git/Git_svn_hash_BmjclS: Bad file descriptor
Date: Wed, 25 Feb 2015 02:19:55 -0800 [thread overview]
Message-ID: <801181a93d829d68b96c4b61d1ebdc3@74d39fa044aa309eaea14b9f57fe79c> (raw)
In-Reply-To: <20150217061707.GA4308@dcvr.yhbt.net>
I believe I have been able to track down this problem and implement a
fix. Please report back if this patch fixes the problem for you.
-Kyle
-- 8< --
Subject: [PATCH] Git::SVN::Fetcher: avoid premature 'svn_hash' temp file closure
Since b19138b (git-svn: Make it incrementally faster by minimizing temp
files, v1.6.0), git-svn has been using the Git.pm temp_acquire and
temp_release mechanism to avoid unnecessary temp file churn and provide
a speed boost.
However, that change introduced a call to temp_acquire inside the
Git::SVN::Fetcher::close_file function for an 'svn_hash' temp file.
Because an SVN::Pool is active at the time this function is called, if
the Git::temp_acquire function ends up actually creating a new
FileHandle for the temp file (which it will the first time it's called
with the name 'svn_hash') that FileHandle will end up in the SVN::Pool
and should that pool have SVN::Pool::clear called on it that FileHandle
will be closed out from under Git::temp_acquire.
Since the only call site to Git::temp_acquire with the name 'svn_hash'
is inside the close_file function, if an 'svn_hash' temp file is ever
created its FileHandle is guaranteed to be created in the active
SVN::Pool.
This has not been a problem in the past because the SVN::Pool was not
being cleared. However, since dfa72fdb (git-svn: reload RA every
log-window-size, v2.2.0) the pool has been getting cleared periodically
at which point the FileHandle for the 'svn_hash' temp file gets closed.
Any subsequent calls to Git::temp_acquire for 'svn_hash', however,
succeed without creating/opening a new temporary file since it still has
the now invalid FileHandle in its cache. Callers that then attempt to
use that FileHandle fail with an error.
We avoid this problem by making sure the 'svn_hash' temp file is created
in the same place the 'svn_delta_...' and 'git_blob_...' temp files are
(and then temp_release'd) so that it can be safely used inside the
close_file function without having its FileHandle end up in an SVN::Pool
that gets cleared.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
---
perl/Git/SVN/Fetcher.pm | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 10edb277..613055a3 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -322,6 +322,14 @@ sub apply_textdelta {
# (but $base does not,) so dup() it for reading in close_file
open my $dup, '<&', $fh or croak $!;
my $base = $::_repository->temp_acquire("git_blob_${$}_$suffix");
+ # close_file may call temp_acquire on 'svn_hash', but because of the
+ # call chain, if the temp_acquire call from close_file ends up being the
+ # call that first creates the 'svn_hash' temp file, then the FileHandle
+ # that's created as a result will end up in an SVN::Pool that we clear
+ # in SVN::Ra::gs_fetch_loop_common. Avoid that by making sure the
+ # 'svn_hash' FileHandle is already created before close_file is called.
+ my $tmp_fh = $::_repository->temp_acquire('svn_hash');
+ $::_repository->temp_release($tmp_fh, 1);
if ($fb->{blob}) {
my ($base_is_link, $size);
--
next prev parent reply other threads:[~2015-02-25 10:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 22:03 git svn import failure : write .git/Git_svn_hash_BmjclS: Bad file descriptor Valery Yundin
2015-01-29 23:34 ` Eric Wong
2015-01-29 23:59 ` Valery Yundin
2015-01-30 0:22 ` Eric Wong
2015-01-30 0:40 ` Valery Yundin
2015-01-30 1:30 ` Eric Wong
2015-01-31 12:51 ` Nico Schlömer
2015-01-31 14:52 ` Valery Yundin
2015-02-12 19:18 ` Eric Wong
2015-02-16 15:10 ` Nico Schlömer
2015-02-17 6:17 ` Eric Wong
2015-02-25 10:19 ` Kyle J. McKay [this message]
[not found] ` <CAK6Z60fqEkM_tON6tcnwBqJzBCvLB=eVJdyXSnNb7N1iR_DSsw@mail.gmail.com>
2015-02-25 20:08 ` Eric Wong
2015-02-25 20:33 ` Kyle J. McKay
[not found] <CAK6Z60ciheWOUGOv1sYcA==B2WR1Rs_eMU+9a=R3FBwc_37CyQ@mail.gmail.com>
2015-02-26 9:09 ` Nico Schlömer
2015-02-26 13:49 ` Kyle J. McKay
2015-02-26 21:27 ` Eric Wong
2015-03-23 19:11 ` Junio C Hamano
2015-03-23 19:36 ` Eric Wong
2015-03-23 19:56 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2015-01-16 17:13 Mike
2015-01-08 12:43 Minty
2015-01-08 17:51 ` Minty
2015-01-14 1:50 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=801181a93d829d68b96c4b61d1ebdc3@74d39fa044aa309eaea14b9f57fe79c \
--to=mackyle@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ipso@snappymail.ca \
--cc=mintywalker@gmail.com \
--cc=nico.schloemer@gmail.com \
--cc=normalperson@yhbt.net \
--cc=yuvalery@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).