git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Lockless Refs?

From
MFMartin Fick <mfick@codeaurora.org>
Date
Dec 29, 2012, 01:07 UTC
Message-ID
<201212281807.23533.mfick@codeaurora.org>
In-Reply-To
<7vlicijepv.fsf@alter.siamese.dyndns.org>

On Friday, December 28, 2012 09:58:36 am Junio C Hamano wrote:

Show 10 quoted lines
> Martin Fick <mfick@codeaurora.org> writes:
> > 3) To create a ref, it must be renamed from the null
> > file (sha 0000...) to the new value just as if it were
> > being updated from any other value, but there is one
> > extra condition: before renaming the null file, a full
> > directory scan must be done to ensure that the null
> > file is the only file in the directory...
> 
> While you are scanning this directory to make sure it is
> empty, 

The objective is not to scan for an empty dir, but to scan for the existence of only the null file.

> I am contemplating to create the same ref with a
> different value.  You finished checking but haven't
> created the null.

The scan needs to happen after creating the null, not before, so I don't believe the rest of the scenario below is possible then?

Show 5 quoted lines
> I have also scanned, created the null
> and renamed it to my value.  Now you try to create the
> null, succeed, and then rename.  We won't know which of
> the two non-null values are valid, but worse yet, I think
> one of them should have failed in the first place.
> Sounds like we would need some form of locking around
> here.  Is your goal "no locks", or "less locks"?
(answered below)
Show 5 quoted lines
> > I don't know how this new scheme could be made to work
> > with the current scheme,...
> 
> It is much more important to know if/why yours is better
> than the current scheme in the first place.  

The goal is: "no locks which do not have a clearly defined reliable recovery procedure".

Stale locks without a reliable recovery procedure will lead to stolen locks. At this point it is only a matter of luck whether this leads to data loss or not. So I do hope to convince people first that the current scheme is bad, not that my scheme is better! My scheme was proposed to get people thinking that we may not have to use locks to get reliable updates.

> Without an
> analysis on how the new scheme interacts with the packed
> refs and gives better behaviour, that is kinda difficult.

Fair enough. I will attempt this if the basic idea seems at least sane? I do hope that eventually the packed-refs piece and its locking will be reconsidered also; as Michael pointed out it has issues already. So, I am hoping to get people thinking more about lockless approaches to all the pieces. I think I have some solutions to some of the other pieces also, but I don't want to overwhelm the discussion all at once (especially if my first piece is shown to be flawed, or if no one has any interest in eliminating the current locks?)

 
Show 6 quoted lines
> I think transition plans can wait until that is done.  If
> it is not even marginally better, we do not have to worry
> about transitioning at all.  If it is only marginally
> better, the transition has to be designed to be no impact
> to the existing repositories.  If it is vastly better, we
> might be able to afford a flag day.
OK, makes sense, I jumped the gun a bit,
-Martin
Previous: Junio C HamanoNext: Jeff King
Message 11 of 23 in “refs: do not use cached refs in repack_without_ref”
  1. refs: do not use cached refs in repack_without_refJeff King, Dec 21, 2012
  2. Michael HaggertyDec 26, 2012
  3. Lockless Refs? (Was [PATCH] refs: do not use cached refs in repack_without_ref)Martin Fick, Dec 27, 2012
  4. Martin FickDec 28, 2012
  5. Junio C HamanoDec 28, 2012
  6. Jeff KingDec 29, 2012
  7. Martin FickDec 29, 2012
  8. Jeff KingDec 29, 2012
  9. Martin FickDec 29, 2012
  10. Junio C HamanoDec 28, 2012
  11. Martin FickDec 29, 2012
  12. Jeff KingDec 29, 2012
  13. Martin FickDec 29, 2012
  14. Martin FickDec 30, 2012
  15. Martin FickDec 31, 2012
  16. Martin FickJan 3, 2013
  17. Pyeron, Jason J CTR (US)Jan 4, 2013
  18. Martin FickJan 4, 2013
  19. Junio C HamanoJan 4, 2013
  20. Jeff KingJan 5, 2013
  21. Drew NorthupJan 22, 2013
  22. Jeff KingDec 29, 2012
  23. Martin FickJan 7, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.