Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 47285: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 |
comparison
equal
deleted
inserted
replaced
47284:21ed126bab53 | 47285:46b828b85eb7 |
---|---|
2188 header = self.index.pack_header(header) | 2188 header = self.index.pack_header(header) |
2189 e = header + e | 2189 e = header + e |
2190 fp.write(e) | 2190 fp.write(e) |
2191 if self._docket is not None: | 2191 if self._docket is not None: |
2192 self._docket.index_end = fp.tell() | 2192 self._docket.index_end = fp.tell() |
2193 | |
2194 # There is a small transactional race here. If the rename of | |
2195 # the index fails, we should remove the datafile. It is more | |
2196 # important to ensure that the data file is not truncated | |
2197 # when the index is replaced as otherwise data is lost. | |
2198 tr.replace(self._datafile, self.start(trindex)) | |
2199 | |
2193 # the temp file replace the real index when we exit the context | 2200 # the temp file replace the real index when we exit the context |
2194 # manager | 2201 # manager |
2195 | 2202 |
2196 tr.replace(self._indexfile, trindex * self.index.entry_size) | 2203 tr.replace(self._indexfile, trindex * self.index.entry_size) |
2197 nodemaputil.setup_persistent_nodemap(tr, self) | 2204 nodemaputil.setup_persistent_nodemap(tr, self) |