[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Pristine store - spec

From: Greg Stein <gstein_at_gmail.com>
Date: Tue, 15 Feb 2011 10:54:26 -0500

On Tue, Feb 15, 2011 at 10:06, Julian Foad <julian.foad_at_wandisco.com> wrote:
>...
>  * ==== Operating Procedures ====
>  *
>  * The steps should be carried out in the order specified.  (See rationale.)
>  *
>  * * To add a pristine, do the following inside an SDB txn:
>  *      * Add the table row, and set the refcount as desired.  If a row
>  *        already exists, add the desired refcount to its refcount, and
>  *        preferably verify the old row matches the new metadata.
>  *      * Create the file. Creation should be fs-atomic, e.g. by moving a
>  *        new file into place, so as never to orphan a partial file.  If a
>  *        file already exists, preferably leave it rather than replace it,
>  *        and optionally verify it matches the new metadata (e.g. length).
>  *
>  * * To remove a pristine, do the following inside an SDB txn:
>  *      * First, check refcount == 0, and abort if not.
>  *      * Delete the table row.
>  *      * Delete the file or move it away. (If not present, log a
>  *        consistency error but, in a release build, return success.)
>  *
>  * * To query a pristine's existence or SDB metadata, the reader must:
>  *      * Ensure no pristine-remove txn is in progress while querying it.

What does "pristine-remove txn" mean?

>  *
>  * * To read a pristine text, the reader must:
>  *      * Ensure no pristine-remove txn is in progress while querying and
>  *        opening it.
>  *      * Ensure the pristine text remains in the store continuously from
>  *        opening it for the duration of the read. (Perhaps by ensuring
>  *        refcount remains >= 1 and/or by cooperating with the clean-up
>  *        code.)

Taking out a WC lock would prevent a pristine from being deleted, right?

>...
>  * ==== Notes ====
>  *
>  * * This procedure can leave orphaned pristine files (files without a
>  *   corresponding SDB row) if Subvsersion crashes.  The Pristine Store
>  *   will still operate correctly.  It should be easy to teach "svn cleanup"
>  *   to safely delete these.  ### Do we need to define the clean-up
>  *   procedure here?
>  *
>  * * This specification is conceptually simple, but requires completing disk
>  *   operations within SDB transactions, which may make it too inefficient
>  *   in practice.  An alternative specification could use the Work Queue to
>  *   enable more efficient processing of multiple transactions.

Note that my initial design for the pristine inserted a row which
effectively said "we know about this pristine, but it hasn't been
written yet". The file would be put into place, then the row would get
tweaked to say "it is now there". That avoids the disk I/O within a
sqlite txn.

>...
>  * === Invariants in a Valid WC DB State ===
>  *
>  * * No pristine text, even if refcount == 0, will be deleted from the store
>  *   as long as any process holds any WC lock in this WC.
>  *
>  * The following conditions are always true outside of a SQL txn:
>  *
>  *   * The 'checksum' column in each NODES table row is either NULL or
>  *     references a primary key in the 'pristine' table.
>  *
>  *   * The 'refcount' column in each PRISTINE table row is equal to the
>  *     number of NODES table rows whose 'checksum' column references this
>  *     pristine row.

ACTUAL_NODE also holds references. Shouldn't these count towards the checksum?

>  *
>  * The following conditions are always true
>  *     outside of a SQL txn,
>  *     when the Work Queue is empty:
>  *     (### ?) when no WC locks are held by any process:
>  *
>  *   * The 'refcount' column in a PRISTINE table row equals the number of
>  *     NODES table rows whose 'checksum' column references that pristine row.
>  *     It may be zero.

hmm? duplicate text?

>  *
>  * ==== Operating Procedures ====
>  *
>  * The steps should be carried out in the order specified.
>  *
>  * * To add a pristine text reference to the WC, obtain the text and its
>  *   checksum, and then do this while holding a WC lock:
>  *     * Add the pristine text to the Pristine Store, setting the desired
>  *       refcount >= 1.
>  *     * Add the reference(s) in the NODES table.
>  *
>  * * To remove a pristine text reference from the WC, do this while holding
>  *   a WC lock:
>  *     * Remove the reference(s) in the NODES table.
>  *     * Decrement the pristine text's 'refcount' column.
>  *
>  * * To purge an unreferenced pristine text, do this with an *exclusive*
>  *   WC lock:
>  *     * Check refcount == 0; skip if not.
>  *     * Remove it from the pristine store.

This seems a bit duplicative of the "Operating Procedures" in the first section.

Cheers,
-g
Received on 2011-02-15 16:55:02 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.