From: Marketa Calabkova <mcalabkova@suse.cz>
To: git@vger.kernel.org
Subject: Re: Worktree creation race
Date: Mon, 28 Jan 2019 13:58:05 +0100 [thread overview]
Message-ID: <2ee89ff3-e672-e940-f601-aa1d2647756a@suse.cz> (raw)
In-Reply-To: <89985b60-4c28-ebf0-64b1-8da75263d745@suse.cz>
[-- Attachment #1.1: Type: text/plain, Size: 1704 bytes --]
Hi,
you have probably overseen my email :) . Please, I would like to get it
fixed.
Does anyone has a suggestion what to do with this bug? It looks like a
one-line fix probably in builtin/worktree.c, but I have no idea how to
do it. Sorry.
Thank you,
Marketa
On 15/01/2019 15:03, Marketa Calabkova wrote:
> Hello,
>
> I am writing to report a bug. The original report is from my colleague, I am also providing his suggestions.
>
> There is insufficient locking for worktree addition. Adding worktree may fail.
>
> The problem is that git reads the directory entries in $GIT_DIR/worktrees,
> finds a worktree name that does not exist, tries to create it, and if an
> error is returned adding the worktree fails. When multiple git processes
> do this in parallel only one adds a worktree and the others fail. Git should
> reread the directory and find a new name that does not exist when creating
> the worktree directory fails because another git process already created it.
>
> I suppose adding PID in the tree name would mitigate the issue to the point it will be very unlikely to encounter.
>
> I need more than the tree in the temporary directory so using the temporary directory directly as a tree is out of question.
>
> to test:
>
> cd /dev/shm
> mkdir gittest
> cd gittest
> git init gitrepo
> cd gitrepo
> git commit --allow-empty -m Empty
> for n in $(seq 10000) ; do ( tmp=$(mktemp -d /dev/shm/gittest/test.XXXXXXXXXXX) ; mkdir $tmp/test ; git worktree add --detach $tmp/test ; ) & done
>
> (you should see many messages like:
> fatal: could not create directory of '.git/worktrees/test284': File exists)
>
> Greetings,
> Marketa
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-01-28 12:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-15 14:03 Worktree creation race Marketa Calabkova
2019-01-28 12:58 ` Marketa Calabkova [this message]
2019-02-01 6:27 ` Eric Sunshine
2019-02-01 7:06 ` Duy Nguyen
2019-02-01 13:16 ` Duy Nguyen
2019-02-01 19:54 ` Eric Sunshine
2019-02-01 18:06 ` Junio C Hamano
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=2ee89ff3-e672-e940-f601-aa1d2647756a@suse.cz \
--to=mcalabkova@suse.cz \
--cc=git@vger.kernel.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.
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).