From: Jeff King <peff@peff.net>
To: Martin Langhoff <martin.langhoff@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Martin Fick <mfick@codeaurora.org>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Diagnosing stray/stale .keep files -- explore what is in a pack?
Date: Tue, 21 Jan 2014 00:19:56 -0500 [thread overview]
Message-ID: <20140121051956.GA5878@sigill.intra.peff.net> (raw)
In-Reply-To: <CACPiFC+koU1Fan+tbE2YgOstWGsDtDihpK-7CMOct7XAEpwJ2A@mail.gmail.com>
On Wed, Jan 15, 2014 at 06:50:33PM -0500, Martin Langhoff wrote:
> On Wed, Jan 15, 2014 at 12:49 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > As long as we can reliably determine that it is safe to do so
> > without risking races, automatically cleaning .lock files is a good
> > thing to do.
>
> If the .lock file is a day old, it seems to me that it should be safe
> to call it stale.
Probably. The way our "lease" system works, nobody should be
holding a ref lock for more than a few milliseconds.
That being said, we do lock other things, like the index. Generally I
think the index lock should be quick, too. And similar for config file
rewrites, and shallow files. And rerere files, it looks like. My, "git
grep commit_lock_file" turns up a lot of hits. :)
So I think all of the existing uses are fine, and I suppose that most
new cases should be fine, too, because git processes tend not to last a
long time.
You asked earlier if I had a script for cleaning locks. No code worth
sharing, but I'll give an outline of what we do at GitHub. We basically
do:
find -name *.lock -mmin +60 | xargs rm
I.e., we give only an hour. For keep files, we give a day (since things
like hooks may run for a while under the lock, though a day is probably
excessive). And we check that it begins with "^receive-pack".
As far as I know, neither of these has ever caused any problems. Of
course, any problems might not be immediately obvious.
> Can anyone "take the lock" if there is already a lock file?
Git never takes an existing lock. It expects you to clean it up
yourself.
> For the keep files, I already drafted a script that looks inside the
> keep file, if it reads 'receive-pack [pid] [host]' it checks whether
> the hostname matches, and if so whether the pid matches a running
> process.
>
> Only if the host matches and the pid is dead we call it stale.
That sounds reasonable.
> Seems fairly conservative to me. Are there scenarios where we think
> this can misfire?
I cannot think of any.
-Peff
prev parent reply other threads:[~2014-01-21 5:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 14:54 Diagnosing stray/stale .keep files -- explore what is in a pack? Martin Langhoff
2014-01-14 17:10 ` Martin Langhoff
2014-01-14 19:36 ` Martin Fick
2014-01-14 19:42 ` Martin Langhoff
2014-01-15 9:12 ` Jeff King
2014-01-15 13:42 ` Martin Langhoff
2014-01-15 17:49 ` Junio C Hamano
2014-01-15 23:50 ` Martin Langhoff
2014-01-16 1:14 ` Duy Nguyen
2014-01-21 5:19 ` Jeff King [this message]
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=20140121051956.GA5878@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=martin.langhoff@gmail.com \
--cc=mfick@codeaurora.org \
/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).