Bug 1626393 - [tryselect] Catch OSError to check for file existence while invalidating task caches, r=gbrown

This prevents a race condition where the watchman hook can potentially
invalidate the cache in-between the call to 'isfile' and 'getmtime'.

Depends on D69189

Differential Revision: https://phabricator.services.mozilla.com/D69190

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2020-04-01 15:12:33 +00:00
Родитель be64ef9701
Коммит ba40f078a0
1 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -40,12 +40,19 @@ https://firefox-source-docs.mozilla.org/taskcluster/taskcluster/mach.html#parame
def invalidate(cache):
if not os.path.isfile(cache):
return
try:
cmod = os.path.getmtime(cache)
except OSError as e:
# File does not exist. We catch OSError rather than use `isfile`
# because the recommended watchman hook could possibly invalidate the
# cache in-between the check to `isfile` and the call to `getmtime`
# below.
if e.errno == 2:
return
raise
tc_dir = os.path.join(build.topsrcdir, 'taskcluster')
tmod = max(os.path.getmtime(os.path.join(tc_dir, p)) for p, _ in FileFinder(tc_dir))
cmod = os.path.getmtime(cache)
if tmod > cmod:
os.remove(cache)