[darcs-devel] Filesystem in DB, but data in filesystem

David Roundy droundy at darcs.net
Mon Aug 6 11:06:04 PDT 2007


On Sun, Aug 05, 2007 at 11:55:02PM +0200, Salvatore Insalaco wrote:
> 2007/8/4, David Roundy <droundy at darcs.net>:
> > Here's something that should be pretty easy to do in combination with the
> > above, if you design it in: atomic updates.  Atomic updates are actually
> > pretty easy, since renameFile is atomic (except on Windows, where atomic
> > updates aren't possible, so far as I know), and all of darcs' file-writing
> > functions write a temp file first and then rename it to overwrite the
> > existing file.  So if you write the new index and all files it indexes in
> > the right order, the result is an atomic update, which will be very nice.
> 
> Do you mean something like:
> 1) Copy the file index
> 2) Write down all the temp files
> 3) Update the file index copy to point to temp files instead of real ones
> 4) Rename the file index to overwrite the original one
> 
> In this way, yes, we could achieve atomic updates, if renames are
> atomic (if they are not, the only place when something can go wrong is
> during the final rename, so we can arrange darcs repair to detect it
> and complete the trasaction).

Yes, that's precisely what I mean.  Also, even if the rename isn't atomic,
it's very fast, so the odds of darcs failing during that rename are very
slim.  Far better than the current state, when *huge* amounts of time could
be spent during which darcs is in a very unhappy state.

Also, the way the code is currently structured, we can construct a
"tentative" index, which is built ahead-of-time (and cleaned up if the
darcs command is cancelled), which also helps reduce the amount of work
which is done during the risky part of the update process.

> I'm a bit quiet lately, that's because I'm on vacation. I'll be back
> at the end of month, until then I'll look at the mailing list once in
> a while.

No problem! I certainly hope that when you get back you'll have the time
and energy toi work on this, though.  :)
-- 
David Roundy
Department of Physics
Oregon State University


More information about the darcs-devel mailing list