[PATCH 2 of 2 RFC] localrepo: make it possible to use flock in a repo

Jun Wu quark at fb.com
Sat May 20 00:06:48 EDT 2017


Excerpts from Gregory Szorc's message of 2017-05-19 20:49:47 -0700:
> OK. I failed to understand that it is locking directories and not files.
> 
> I don't want to go down this rat hole, but since it may help my point...
> 
> The next store format will likely use some form of "generational store."
> Files protected by transactions that aren't append only (like bookmarks and
> phases) will exist in a directory corresponding to their
> transaction/generation number. e.g. .hg/store/txn0/bookmarks,
> .hg/store/txn1500/phaseroots. This allows readers to have consistent
> snapshots since we never rewrite existing bytes: we just copy or create
> files and have a pointer to the "current" generation. In this model you
> have reader locks so you know when there are no more active consumers for a
> generation and can GC its files.
>
> Anyway, the locking model may be radically different. You can't rely on it
> being based on whole directories. So the semantics of a "flock" requirement
> could vary drastically depending on the store and other repo features in
> use. And I think having the semantics of a requirement vary depending on
> the presence of other requirements is not ideal. You want a requirement to
> mean one thing and one thing only and not be subject to multiple
> interpretations.

How about creating files then? For every existing file existence lock at
$PATH, create $PATH.flock first (but never delete or replace it), and then
flock it. That'll be compatible with every file-existence lock (like two
locks under a same directory).

> The "store" requirement was added in Mercurial 0.9.2. The chances of this
> special case of
> no store + flock occurring in 2017 are approximately 0%. I dare say we
> should add code to
> prevent combinations of requirements like this because they make no sense
> and are a footgun waiting to fire. To prove my point, I just created a repo
> with format.usestore=false and experimental.treemanifest=true. It did seem
> to work, surprisingly. But it would be foolish to run such a config given
> the pre-store format has been out of style for over 10 years.


More information about the Mercurial-devel mailing list