Comment 10 for bug 98836

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 98836] Re: [MASTER] dirstate file write locks exclude readers and limit portability

On Tue, 2009-03-24 at 23:36 +0000, Martin Pool wrote:
> The suggestion at the end of that thread as of today is from Robert that
> we should have an indirection file giving the name of the dirstate to
> use, and this should be a minimal change. I previously thought I'd seen
> a problem in that approach, but I can't think of it at the moment.

Concretely:
 - we add a indirection file
 - clients that see a missing file spin on it (as its being updated at
the time)
 - updates to the indirection file are write-and-rename, with a known
backup file name so that an incomplete replacement can be recovered
from.
 - readers can read the file the got pointed at indefinitely.
 - on close, readers check if the file is still pointed at, and if not
   try to rm it, squashing errors (as another reader may be open)
 - normal writers (commit, merge etc) that have a lockdir lock can just
   write a new file and update the indirection file
 - special writers (status etc) would write a new file, and then:
   - write a new indirection tempfile,
   - move the old one away
   - check the old one has the same pointer it had when they started
     - if not, put it back
     - if it does, put their version in place

we may still get stale dirstate files accumulating, so check should rm
ones that look implausibly old.

-Rob