From: Dragan Simic <dsimic@manjaro.org>
To: Stefan Haller <lists@haller-berlin.de>
Cc: git@vger.kernel.org
Subject: Re: Concurrent fetch commands
Date: Sun, 31 Dec 2023 14:48:45 +0100 [thread overview]
Message-ID: <0a98597e270276c67a7aafae20c6d073@manjaro.org> (raw)
In-Reply-To: <c11ca0b3-aaf4-4a8d-80a1-3832954aa7aa@haller-berlin.de>
On 2023-12-31 14:30, Stefan Haller wrote:
> Currently, git doesn't seem to be very good at handling two concurrent
> invocations of git fetch (or git fetch and git pull). This is a problem
> because it is common for git clients to run git fetch periodically in
> the background. In that case, when you happen to invoke git pull while
> such a background fetch is running, an error occurs ("Cannot rebase
> onto
> multiple branches").
>
> I can reliably reproduce this by doing
>
> $ git fetch&; sleep 0.1; git pull
> [1] 42160
> [1] + done git fetch
> fatal: Cannot rebase onto multiple branches.
>
> The reason for this failure seems to be that both the first fetch and
> the fetch that runs as part of the pull append their information to
> .git/FETCH_HEAD, so that the information for the current branch ends up
> twice in the file.
>
> Do you think git fetch should be made more robust against scenarios
> like
> this?
I believe a similar issue has been already raised recently, so perhaps
introducing some kind of file-based locking within git itself could be
justified. It would make the things a bit more robust, and would also
improve the overall user experience.
> More context: the git client that I'm contributing to (lazygit) used to
> guard against this for its own background fetch with a global mutex
> that
> allowed only one single fetch, pull, or push at a time. This solved the
> problem nicely for lazygit's own operations (at the expense of some
> lag,
> occasionally); and I'm not aware of any reports about failures because
> some other git client's background fetch got in the way, so maybe we
> don't have to worry about that too much.
>
> However, we now removed that mutex to allow certain parallel fetch
> operations to run at the same time, most notably fetching (and
> updating)
> a branch that is not checked out (by doing "git fetch origin
> branch:branch"). It is useful to be able to trigger this for multiple
> branches concurrently, and actually this works fine.
>
> But now we have the problem described above, where a pull of the
> checked-out branch runs at the same time as a background fetch; this is
> not so unlikely, because lazygit triggers the first background fetch at
> startup, so invoking the pull command right after starting lazygit is
> very likely to fail.
>
> We could re-introduce a mutex and just make it a little less global;
> e.g. protect only pull and parameter-less fetch. But fixing it in git
> itself seems preferable to me.
>
> Sorry for the wall of text, but I figured giving more context could be
> useful.
next prev parent reply other threads:[~2023-12-31 13:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-31 13:30 Concurrent fetch commands Stefan Haller
2023-12-31 13:48 ` Dragan Simic [this message]
2023-12-31 13:50 ` Konstantin Tokarev
2023-12-31 14:01 ` Dragan Simic
2024-01-01 11:23 ` Stefan Haller
2024-01-01 15:47 ` Federico Kircheis
2023-12-31 17:27 ` Junio C Hamano
2023-12-31 17:41 ` Dragan Simic
2024-01-01 11:30 ` Stefan Haller
2024-01-01 11:42 ` Stefan Haller
2024-01-03 7:33 ` Patrick Steinhardt
2024-01-03 8:11 ` Patrick Steinhardt
[not found] ` <ZZU1TCyQdLqoLxPw@ugly>
2024-01-03 10:40 ` Patrick Steinhardt
2024-01-03 16:40 ` Taylor Blau
2024-01-03 22:10 ` Junio C Hamano
2024-01-04 12:01 ` Stefan Haller
2024-01-04 20:54 ` Mike Hommey
2024-01-04 22:14 ` Junio C Hamano
2024-01-04 22:25 ` Mike Hommey
2024-01-04 17:34 ` Taylor Blau
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0a98597e270276c67a7aafae20c6d073@manjaro.org \
--to=dsimic@manjaro.org \
--cc=git@vger.kernel.org \
--cc=lists@haller-berlin.de \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).