From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, Heiko Voigt <hvoigt@hvoigt.net>,
git@vger.kernel.org
Subject: Re: [PATCH 17/33] repack_without_ref(): silence errors for dangling packed refs
Date: Wed, 17 Apr 2013 10:41:19 +0200 [thread overview]
Message-ID: <516E602F.3090703@alum.mit.edu> (raw)
In-Reply-To: <7vhaj7vgk6.fsf@alter.siamese.dyndns.org>
On 04/15/2013 07:39 PM, Junio C Hamano wrote:
> Michael Haggerty <mhagger@alum.mit.edu> writes:
>
>> Stop emitting an error message for dangling packed references found
>> when deleting another packed reference. See the previous commit for a
>> longer explanation of the issue.
>>
>> Change repack_without_ref_fn() to silently ignore dangling packed
>> references.
>>
>> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
>
> Somehow this feels as if it is sweeping the problem under the rug.
>
> If you ignore a ref for which a loose ref exists when you update a
> packed refs file, whether the stale "packed" one points at an object
> that is still there or an object that has been garbage collected,
> you would not even have to check if the "ref" resolves to object or
> anything like that, no?
>
> Am I missing something?
>
> This one feels iffy in the otherwise pleasant-to-read series.
The usual situation when this code would be triggered would be that the
packed reference is overridden by a loose ref and points at an object
that has been garbage collected. In that case it is definitely
incorrect to emit an error message.
But the fact that we don't explicitly verify that there is an overriding
loose reference means that it is possible that the failure to resolve
the packed ref comes from some kind of repository corruption, and you
are correct that such a problem would be swept under the rug by my change.
I've been trying to minimize the extra work that repack_without_ref()
needs to do to write peeled references, to avoid stretching out the
delay that can now occur when deleting a reference. Thus I was trying
to save a check of loose references during this operation. But I guess
I agree that a little bit more caution would be prudent.
I can think of a few ways to avoid sweeping possible indications of repo
corruption under the rug, in order of increasing run-time:
1. If a packed ref's SHA-1 cannot be resolved, write the packed ref to
the new packed-refs file anyway with SHA-1 but without a peeled value.
This would avoid having to check the loose references and avoid erasing
possible evidence of corruption, but would delay an actual check for
corruption until a later time. It would be a quick fix, effectively
kicking the can down the road instead of sweeping it under the rug.
Minor pitfall: a reference that is listed without a peeled value in a
fully-peeled pack-refs file tells future readers that the corresponding
SHA-1 *cannot* be peeled. IF the named object would somehow reappear in
the repository (e.g., via a fetch) and IF the object is peelable and IF
there is in fact no loose ref overriding the packed ref, then the final
result would be that one form of corruption (reference points to
non-existent object) would be converted to another form (reference
falsely believed to be non-peelable). I think this is an acceptable
risk because (a) it would only happen in an unlikely series of events in
a repo that was already corrupt, and (b) because falsely believing a
reference to be non-peelable wouldn't have terrible consequences.
2. Whenever a packed reference cannot be resolved to an object, verify
that there is indeed a loose reference overriding it; if not, emit an
error and in either case omit the packed ref from the output.
3. Check for an overriding loose reference *before* trying to peel a
packed reference, and omit any overridden loose references from the
output packed-refs file. This would be close to running "pack-refs
--no-prune" without the "is_tag_ref" test and with reuse of available
peeled values. This approach would tidy up the packed-refs file a bit
more than (2) because it would cause the deletion of more overridden
packed refs, but only as part of first peeling them, which should only
happen once in a repo, and only if the first peeling occurs within
repack_without_ref() as opposed to an explicit pack_refs(). So it's a
negligible improvement over (2).
4. Further along the "correctness" spectrum, one could check for
overriding loose references *every* time the packed-refs file is
rewritten by repack_without_ref(), even for references whose peeled
values are already known. But this would add overhead to every deletion
of a packed reference, which is probably not justified.
I'm worried that implementing 2-4 would introduce new race conditions of
the type that Peff discovered recently, unless we fix the locking policy
first (which is also on my TODO list). So my suggestion is to implement
1 now and implement 2 sometime in the future.
Opinions?
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
next prev parent reply other threads:[~2013-04-17 8:48 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-14 12:54 [PATCH 00/33] Various cleanups around reference packing and peeling Michael Haggerty
2013-04-14 12:54 ` [PATCH 01/33] refs: document flags constants REF_* Michael Haggerty
2013-04-14 12:54 ` [PATCH 02/33] refs: document the fields of struct ref_value Michael Haggerty
2013-04-14 12:54 ` [PATCH 03/33] refs: document do_for_each_ref() and do_one_ref() Michael Haggerty
2013-04-15 17:38 ` Junio C Hamano
2013-04-16 9:11 ` Michael Haggerty
2013-04-14 12:54 ` [PATCH 04/33] refs: document how current_ref is used Michael Haggerty
2013-04-14 12:54 ` [PATCH 05/33] refs: define constant PEELED_LINE_LENGTH Michael Haggerty
2013-04-14 12:54 ` [PATCH 06/33] do_for_each_ref_in_dirs(): remove dead code Michael Haggerty
2013-04-14 12:54 ` [PATCH 07/33] get_packed_ref(): return a ref_entry Michael Haggerty
2013-04-14 12:54 ` [PATCH 08/33] peel_ref(): use function get_packed_ref() Michael Haggerty
2013-04-14 12:54 ` [PATCH 09/33] repack_without_ref(): " Michael Haggerty
2013-04-14 12:54 ` [PATCH 10/33] refs: extract a function ref_resolves_to_object() Michael Haggerty
2013-04-15 16:51 ` Junio C Hamano
2013-04-16 9:27 ` Michael Haggerty
2013-04-16 18:08 ` Junio C Hamano
2013-04-14 12:54 ` [PATCH 11/33] refs: extract function peel_object() Michael Haggerty
2013-04-14 12:54 ` [PATCH 12/33] peel_object(): give more specific information in return value Michael Haggerty
2013-04-15 17:38 ` Junio C Hamano
2013-04-14 12:54 ` [PATCH 13/33] peel_ref(): fix return value for non-peelable, not-current reference Michael Haggerty
2013-04-15 17:38 ` Junio C Hamano
2013-04-16 9:38 ` Michael Haggerty
2013-04-14 12:54 ` [PATCH 14/33] refs: extract a function peel_entry() Michael Haggerty
2013-04-15 17:38 ` Junio C Hamano
2013-04-16 13:07 ` Michael Haggerty
2013-04-16 17:55 ` Junio C Hamano
2013-04-16 22:01 ` Michael Haggerty
2013-04-14 12:54 ` [PATCH 15/33] refs: change the internal reference-iteration API Michael Haggerty
2013-04-15 17:38 ` Junio C Hamano
2013-04-16 13:27 ` Michael Haggerty
2013-04-16 17:47 ` Junio C Hamano
2013-04-14 12:54 ` [PATCH 16/33] t3210: test for spurious error messages for dangling packed refs Michael Haggerty
2013-04-15 17:39 ` Junio C Hamano
2013-04-16 14:14 ` Michael Haggerty
2013-04-16 23:22 ` Junio C Hamano
2013-04-16 23:57 ` Jeff King
2013-04-17 4:42 ` Junio C Hamano
2013-04-17 22:38 ` Junio C Hamano
2013-04-18 7:46 ` [PATCH 0/2] Add documentation for new expiry option values Michael Haggerty
2013-04-18 7:46 ` [PATCH 1/2] git-gc.txt, git-reflog.txt: document new expiry options Michael Haggerty
2013-04-18 7:46 ` [PATCH 2/2] api-parse-options.txt: document "no-" for non-boolean options Michael Haggerty
2013-04-25 18:13 ` [PATCH] prune: introduce OPT_EXPIRY_DATE() and use it Junio C Hamano
2013-04-17 8:11 ` [PATCH 16/33] t3210: test for spurious error messages for dangling packed refs Michael Haggerty
2013-04-14 12:54 ` [PATCH 17/33] repack_without_ref(): silence errors " Michael Haggerty
2013-04-15 17:39 ` Junio C Hamano
2013-04-17 8:41 ` Michael Haggerty [this message]
2013-04-14 12:54 ` [PATCH 18/33] search_ref_dir(): return an index rather than a pointer Michael Haggerty
2013-04-14 12:54 ` [PATCH 19/33] refs: change how packed refs are deleted Michael Haggerty
2013-04-14 12:54 ` [PATCH 20/33] t3211: demonstrate loss of peeled refs if a packed ref is deleted Michael Haggerty
2013-04-14 12:54 ` [PATCH 21/33] repack_without_ref(): write peeled refs in the rewritten file Michael Haggerty
2013-04-15 17:39 ` Junio C Hamano
2013-04-14 12:54 ` [PATCH 22/33] refs: extract a function write_packed_entry() Michael Haggerty
2013-04-14 12:54 ` [PATCH 23/33] pack-refs: rename handle_one_ref() to pack_one_ref() Michael Haggerty
2013-04-14 12:54 ` [PATCH 24/33] pack-refs: merge code from pack-refs.{c,h} into refs.{c,h} Michael Haggerty
2013-04-14 12:54 ` [PATCH 25/33] pack_one_ref(): rename "path" parameter to "refname" Michael Haggerty
2013-04-14 12:54 ` [PATCH 26/33] refs: use same lock_file object for both ref-packing functions Michael Haggerty
2013-04-14 12:54 ` [PATCH 27/33] pack_refs(): change to use do_for_each_entry() Michael Haggerty
2013-04-14 12:54 ` [PATCH 28/33] refs: inline function do_not_prune() Michael Haggerty
2013-04-14 12:54 ` [PATCH 29/33] pack_one_ref(): use function peel_entry() Michael Haggerty
2013-04-14 12:54 ` [PATCH 30/33] pack_one_ref(): use write_packed_entry() to do the writing Michael Haggerty
2013-04-14 12:54 ` [PATCH 31/33] pack_one_ref(): do some cheap tests before a more expensive one Michael Haggerty
2013-04-14 12:54 ` [PATCH 32/33] refs: change do_for_each_*() functions to take ref_cache arguments Michael Haggerty
2013-04-15 17:40 ` Junio C Hamano
2013-04-14 12:54 ` [PATCH 33/33] refs: handle the main ref_cache specially Michael Haggerty
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=516E602F.3090703@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hvoigt@hvoigt.net \
--cc=peff@peff.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).