[PATCH 08 of 10] repair: migrate revlogs during upgrade

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Nov 23 10:36:03 EST 2016



On 11/06/2016 05:40 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1478393405 25200
> #      Sat Nov 05 17:50:05 2016 -0700
> # Node ID d2261c558ca9639fb81c182de15d75151cbad0f9
> # Parent  958bcf2577608bbb6d8ae078cde0ca451f3ab31a
> repair: migrate revlogs during upgrade
>
> Our next step for in-place upgrade is to migrate store data. Revlogs
> are the biggest source of data within the store and a store is useless
> without them, so we implement their migration first.
>
> Our strategy for migrating revlogs is to walk the store and call
> `revlog.copy()` on each revlog. There are some minor complications.
>
> Because revlogs have different storage options (e.g. changelog has
> generaldelta and delta chains disabled), we need to obtain the
> correct class of revlog so inserted data is encoded properly for its
> type.
>
> Because manifests are converted after filelogs and because manifest
> conversion can take a long time when large manifests are in play,
> a naive progress bar for revlog count was misleading, as it effectively
> got to 99% and froze there when processing the manifest. So, there is
> a first pass to count revisions and use revisions in the progress bar.
> The extra code is somewhat annoying. But this pass serves a secondary
> useful purpose: ensuring we can open all revlogs that will be copied.
> We don't want to spend several minutes copying revlogs only to
> encounter a permissions error or some such later.
>
> As part of this change, we also add swapping of the store directory
> to the upgrade function. After revlogs are converted, we move the
> old store into the backup directory then move the temporary repo's
> store into the old store's location. On well-behaved systems, this
> should be 2 atomic operations and the window of inconsistency show be
> very narrow.

Silly idea: We could add a "requirement" to the repository while doing 
this. So that reading client would just be rejected (in most case) with 
a proper message while this happens.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list