Re: [PATCH 19/29] refs: don't dereference on rename
From: Junio C Hamano <hidden>
Date: 2016-06-16 02:19:04
Michael Haggerty [off-list ref] writes:
quoted
Could you explain s/sha1/NULL/ here in the proposed log message?Good question. Passing sha1 to delete_ref() doesn't add any safety, because the same sha1 was just read a moment before, and it is not used for anything else.
"... and it is guaranteed that no other process in the meantime wanted to update the ref we are trying to delete because it wants to see the ref with its updated value." is something I expected to see at the end.
So the check only protects us from a concurrent update to newrefname between the call to read_ref_full() and the call to delete_ref(). But such a race is indistinguishable from the case that a modification to newrefname happens just before the call to read_ref_full(), which would have the same outcome as the new code.
In other words, when a transaction that contains a deletion of a ref races with another one that updates the ref, the latter transaction may come after the former one, but the ref may not survive in the end result and can be left deleted? Puzzled...