Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/nodemap.py @ 46089:8ff2d8359d0f
persistent-nodemap: properly ignore non-existent `.nd` data file
This code was meant to handle the case of a nodemap docket file
pointing to a nodemap data file that doesn?t exist (anymore),
but most likely caused an `UnboundLocalError` exception instead
when `data` was used on the next line without being defined.
This case is theoretically possible with a race condition
between two hg processes, but is hard to reproduce or test:
* Process A reads a docket file and finds a UID in it
that points to a given data file name.
* Process B decides that this same data file needs compacting.
It writes a new one with a different UID,
overwrites the docket file,
then removes the old data file.
* Only then process A tries to a open a file that doesn?t exist anymore.
Differential Revision: https://phab.mercurial-scm.org/D9533
author | Simon Sapin <simon-commits@exyr.org> |
---|---|
date | Mon, 07 Dec 2020 18:06:53 +0100 |
parents | 89a2afe31e82 |
children | 59fa3890d40a |
comparison
equal
deleted
inserted
replaced
46088:8837498ae6e0 | 46089:8ff2d8359d0f |
---|---|
56 if use_mmap: | 56 if use_mmap: |
57 data = util.buffer(util.mmapread(fd, data_length)) | 57 data = util.buffer(util.mmapread(fd, data_length)) |
58 else: | 58 else: |
59 data = fd.read(data_length) | 59 data = fd.read(data_length) |
60 except OSError as e: | 60 except OSError as e: |
61 if e.errno != errno.ENOENT: | 61 if e.errno == errno.ENOENT: |
62 return None | |
63 else: | |
62 raise | 64 raise |
63 if len(data) < data_length: | 65 if len(data) < data_length: |
64 return None | 66 return None |
65 return docket, data | 67 return docket, data |
66 | 68 |