From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Remove branch by putting a null sha1 into the ref file.
Date: Sun, 24 Sep 2006 06:45:53 +0200 [thread overview]
Message-ID: <200609240645.54467.chriscool@tuxfamily.org> (raw)
In-Reply-To: <7veju2nthl.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> Christian Couder <chriscool@tuxfamily.org> writes:
> > You are right, so what about moving ".git/refs/heads/frotz"
> > to ".git/deleted-refs/heads/frotz.ref"
> > or ".git/deleted-refs/heads/frotz~ref" (because "~" is forbidden in ref
> > names).
>
> But wouldn't it bring up the issue of locking among deleters,
> updaters/creators, and traversers?
Yes, it will get worse.
> If we choose to use packed-refs.lock as the "set of all refs"
> lock, the whole sequence would become something like this. Note
> that this tries to make readers lockless but I am sure there are
> nasty race condition issues. I am not sure what we would want
> to do about them.
>
> = Looking up a ref $frotz.
We could acquire .git/$frotz.lock here if we want to be sure that nothing
will happen to it while we read it, but anyway something could happen to it
just after we read it and before we use it. So the right thing to do is
perhaps to let the caller acquire the lock if it needs to. We should just
check in the other cases below that nothing can happen to the ref if
someone acquired .git/$frotz.lock.
> - check if .git/$frotz exists, and use it if it does.
>
> - check if .git/deleted-refs/$frotz~ref exists, and return "no
> such ref" if it does.
>
> - find $frotz in .git/packed-refs.
>
> = Looping over refs.
Same as above. Depending on what the caller wants to do, it could
acquire .git/packed-refs.lock or some .git/$frotz.lock to make sure nothing
happens to all or only some refs.
> - grab all .git/refs/ and subtract all .git/deleted-refs/
>
> - walk .git/packed-refs and the result from the above in
> parallel as in the current code.
>
> = Storing a new value in ref $frotz.
>
> - acquire .git/packed-refs.lock
>
> - lock .git/$frotz.lock.
>
> - write into .git/$frotz.lock.
>
> - create or update .git/logs/$frotz as needed.
>
> - if .git/deleted-refs/$frotz~ref exists, unlink it.
>
> - rename .git/$frotz.lock to .git/$frotz to unlock it.
>
> - unlink .git/packed-refs.lock
>
> = Deleting a ref $frotz.
>
> - acquire .git/packed-refs.lock
- acquire .git/$frotz.lock seems needed too
> - look up $frotz; if it does not exist either barf or return
> silent (haven't thought it through yet).
>
> - create .git/deleted-refs/$frotz~ref
or move .git/$frotz to .git/deleted-refs/$frotz~ref if .git/$frotz exists
> - remove .git/logs/$frotz
- unlink .git/$frotz.lock
> - unlink .git/packed-refs.lock
>
> = Packing refs, with optional pruning.
>
> - lock .git/packed-refs.lock
>
> - loop over refs:
> - write it out to .git/packed-refs.lock unless a symref.
> - if it is a loose one (not a symref), remember it for pruning.
>
> - if pruning:
> - remove the entire .git/deleted-refs/ hierarchy
> - remove the remembered ones
Perhaps we should acquire .git/$frotz.lock for each $frotz that we remove
when pruning.
> - rename .git/packed-refs.lock to .git/packed-refs
Thanks,
Christian.
next prev parent reply other threads:[~2006-09-24 4:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-18 4:54 [PATCH] Remove branch by putting a null sha1 into the ref file Christian Couder
2006-09-18 5:47 ` Junio C Hamano
2006-09-18 16:31 ` Linus Torvalds
2006-09-18 18:43 ` Junio C Hamano
2006-09-20 2:56 ` Christian Couder
2006-09-22 22:09 ` Junio C Hamano
2006-09-23 4:45 ` Christian Couder
2006-09-23 8:04 ` Junio C Hamano
2006-09-23 11:22 ` Christian Couder
2006-09-23 21:49 ` Junio C Hamano
2006-09-24 4:45 ` Christian Couder [this message]
2006-09-25 9:26 ` On ref locking Junio C Hamano
2006-09-25 17:05 ` Daniel Barkalow
2006-09-26 4:11 ` Junio C Hamano
2006-09-26 4:13 ` [PATCH 1/3] Clean-up lock-ref implementation Junio C Hamano
2006-09-26 4:13 ` [PATCH 2/3] update-ref: -d flag and ref creation safety Junio C Hamano
2006-09-26 18:05 ` [PATCH 3/3] update a few Porcelain-ish for ref lock safety Junio C Hamano
2006-09-26 18:08 ` Andy Whitcroft
2006-09-27 7:25 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200609240645.54467.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/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).