Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlog.py @ 47296:46b828b85eb7
revlog: update data file record before index rename
When migrating from inline to non-inline data storage, the data file is
recorded initially as zero sized so that it is removed on failure. But
the record has to be updated before the index is renamed, otherwise
data is lost on rollback.
Differential Revision: https://phab.mercurial-scm.org/D10725
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Wed, 19 May 2021 13:46:19 +0200 |
parents | 21ed126bab53 |
children | 93a0abe098e7 |
line wrap: on
line diff
--- a/mercurial/revlog.py Tue May 18 02:35:27 2021 +0200 +++ b/mercurial/revlog.py Wed May 19 13:46:19 2021 +0200 @@ -2190,6 +2190,13 @@ fp.write(e) if self._docket is not None: self._docket.index_end = fp.tell() + + # There is a small transactional race here. If the rename of + # the index fails, we should remove the datafile. It is more + # important to ensure that the data file is not truncated + # when the index is replaced as otherwise data is lost. + tr.replace(self._datafile, self.start(trindex)) + # the temp file replace the real index when we exit the context # manager