Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/filelog.py @ 50316:87f0155d68aa stable
revlog: improve the robustness of the splitting process
The previous "in-place" splitting, preserving the splitting on transaction
failure had a couple of issue in case of transaction rollback:
- a race windows that could still lead to a crash and data loss
- it corrupted the `fncache`.
So instead, we use a new approach that we summarized as "we do a backup of the
inline revlog pre-split, and we restore this in case of failure".
To make readers live easier, we don't overwrite the inline index file until
transaction finalization. (once the transaction get into its finalization phase,
it is not expected to rollback, unless some crash happens).
To do so, we write the index of the split index in a temporary file that we use
until transaction finalization. We also keep a backup of the initial inline file
to be able to rollback the split if needed.
As a result, transaction rollback cancel the split and no longer corrupt
fncache. We also no longer have a small inconsistency windows where the
transaction could be unrecoverable.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 20 Mar 2023 11:52:17 +0100 |
parents | 152d9c011bcd |
children | 32837c7e2e4b |
comparison
equal
deleted
inserted
replaced
50315:cf6e1d535602 | 50316:87f0155d68aa |
---|---|
23 ) | 23 ) |
24 | 24 |
25 | 25 |
26 @interfaceutil.implementer(repository.ifilestorage) | 26 @interfaceutil.implementer(repository.ifilestorage) |
27 class filelog: | 27 class filelog: |
28 def __init__(self, opener, path): | 28 def __init__(self, opener, path, try_split=False): |
29 self._revlog = revlog.revlog( | 29 self._revlog = revlog.revlog( |
30 opener, | 30 opener, |
31 # XXX should use the unencoded path | 31 # XXX should use the unencoded path |
32 target=(revlog_constants.KIND_FILELOG, path), | 32 target=(revlog_constants.KIND_FILELOG, path), |
33 radix=b'/'.join((b'data', path)), | 33 radix=b'/'.join((b'data', path)), |
34 censorable=True, | 34 censorable=True, |
35 canonical_parent_order=False, # see comment in revlog.py | 35 canonical_parent_order=False, # see comment in revlog.py |
36 try_split=try_split, | |
36 ) | 37 ) |
37 # Full name of the user visible file, relative to the repository root. | 38 # Full name of the user visible file, relative to the repository root. |
38 # Used by LFS. | 39 # Used by LFS. |
39 self._revlog.filename = path | 40 self._revlog.filename = path |
40 self.nullid = self._revlog.nullid | 41 self.nullid = self._revlog.nullid |
254 | 255 |
255 | 256 |
256 class narrowfilelog(filelog): | 257 class narrowfilelog(filelog): |
257 """Filelog variation to be used with narrow stores.""" | 258 """Filelog variation to be used with narrow stores.""" |
258 | 259 |
259 def __init__(self, opener, path, narrowmatch): | 260 def __init__(self, opener, path, narrowmatch, try_split=False): |
260 super(narrowfilelog, self).__init__(opener, path) | 261 super(narrowfilelog, self).__init__(opener, path, try_split=try_split) |
261 self._narrowmatch = narrowmatch | 262 self._narrowmatch = narrowmatch |
262 | 263 |
263 def renamed(self, node): | 264 def renamed(self, node): |
264 res = super(narrowfilelog, self).renamed(node) | 265 res = super(narrowfilelog, self).renamed(node) |
265 | 266 |