[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Atomicity idea.
Re: Atomicity idea.
23 Jan 2003 14:24:54 -0800
email@example.com (Kaz Kylheku) wrote in message
> I'm looking at the CVS source code, and thinking about ways to make
> commits and tagging atomic.
> One idea is to do it in a lower layer, and perform only minimal
> instrumentation of the CVS logic: basically insert a few calls to the
> transactional layer into a few key places in CVS.
I have come up with a very simple, low-risk way for doing this. It
assumes that files contents are never destructively manipulated, which
is true: CVS always writes to temporary files and then moves on top.
Here is the scheme. Before doing a commit or tagging operation on a
directory tree, you make a virtual backup of that tree. How? By
faithfully replacing that tree's directory structure under a temporary
directory, and populating it with a farm of hard links to the objects
in the original.
The CVS operation then takes place in the orignal tree. If everything
goes well, the hard-link-based backup tree is blown away. If the
transaction must be rolled back, then the backup tree is installed in
place of the original, and the original is blown away. This is done
using renaming operations on the top level directory names.
Atomic renames at the top level can handle the logic. The backup tree,
while it is constructed, can be named
.#cvs.backup.<dir-name>.incomplete. When constructed, and the logic
moves on to doing the commit operation it is then called
.#cvs.backup.<dir-name>.complete. Then when it is being deleted, it
can go back to the .incomplete name.
During rollback, the original directory is renamed to some special
name before it is recursively deleted, and then the backup directory
is renamed to the original directory name.
Crash recovery can be performed by simple shell scripts, which look
for the presence of these directory names and decide what to blow away
and what to keep.
- Atomicity idea., Kaz Kylheku, 2003/01/22
- Re: Atomicity idea.,
Kaz Kylheku <=