From: Jeff King <peff@peff.net>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Aleksey Midenkov <midenok@gmail.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Bug: fatal: Unable to create '.../.git/index.lock': File exists.
Date: Thu, 2 May 2019 12:58:03 -0400 [thread overview]
Message-ID: <20190502165802.GA19341@sigill.intra.peff.net> (raw)
In-Reply-To: <CACsJy8Dimn9+ogDNEgy3xmLunyX_pStBq=g-1jrf74LsOW1xrA@mail.gmail.com>
On Thu, May 02, 2019 at 11:38:51PM +0700, Duy Nguyen wrote:
> > Since the decision of whether to use the locks is dependent on the
> > operation being performed, it's an environment variable and not a config
> > option.
>
> And there's also tradeoff for doing it. If git-status will not take
> locks, it cannot update the index to save refresh information and
> reuse the next time. git-status may become more and more expensive
> over time (*). Setting a config variable for this does not sound like
> a good idea at all. The same for setting GIT_OPTIONAL_LOCKS=0 in
> ~/.bashrc to "fix" the problem once and for all.
Right. I suspect in the long run it might not be _too_ bad to run with
such a setting, because any non-read operations would eventually refresh
the index (and as you note even many read-only operations like porcelain
git-diff unconditionally refresh for now).
But I agree it's not really the direction we want to go.
> I might take a stab at the "wait and try to hold the lock again, doing
> necessary verification after if needed" idea. It sounds like the right
> way to go and we haven't had problems with refs doing the same thing
> (have we?).
No, but it's a bit easier with refs because the locking is just
atomically checking the lease. I.e., after taking the lock we still say
"we expected the ref to be at oid XYZ, is it still there?". What's the
equivalent for an index operation?
I think it is more common with the index to take the lock, then while
holding it read it in fresh (possibly dumping old results), manipulate
the result, and then write it out. For callers which make sure to
get a fresh view _after_ taking the lock, they should be OK if taking
the lock is delayed.
I guess arguably any callers that aren't that careful are already
broken, since it is a race; any delay-and-retry _could_ have happened as
"we were too slow to see the initial lock".
-Peff
next prev parent reply other threads:[~2019-05-02 16:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAF8BazDu_GqoCPBQ-gEJ+q8n1aWSjf_TOV7bDE5VCQkDgBjyfQ@mail.gmail.com>
2019-04-29 11:02 ` Bug: fatal: Unable to create '.../.git/index.lock': File exists Aleksey Midenkov
2019-04-29 11:34 ` Duy Nguyen
2019-04-30 11:19 ` Aleksey Midenkov
2019-04-30 17:41 ` Jeff King
2019-05-01 7:15 ` Aleksey Midenkov
2019-05-01 18:36 ` Jeff King
2019-05-02 13:45 ` Aleksey Midenkov
2019-05-02 15:07 ` Jeff King
2019-05-02 16:38 ` Duy Nguyen
2019-05-02 16:58 ` Jeff King [this message]
2019-05-02 17:24 ` Duy Nguyen
2019-05-03 9:47 ` Johannes Schindelin
2019-05-03 10:22 ` Duy Nguyen
2019-05-03 5:42 ` Duy Nguyen
2019-04-29 21:10 ` Johannes Schindelin
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=20190502165802.GA19341@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=midenok@gmail.com \
--cc=pclouds@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).