# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2020-09-08 14:06:40 # Node ID 64de86fd0984ff1e2306de52849be7ebf7dcfd25 # Parent 5523e3e1bc717ac155dcd68803dd861fe62414f6 tags: take lock instead of wlock before writing hgtagsfnodes1 cache This cache is shared across stores and hence we should take store lock before writing to it. Otherwise there will be race where one share with wlock is writing to this cache and other share with wlock is trying to read it simultaneously. Differential Revision: https://phab.mercurial-scm.org/D9001 diff --git a/mercurial/tags.py b/mercurial/tags.py --- a/mercurial/tags.py +++ b/mercurial/tags.py @@ -838,7 +838,7 @@ class hgtagsfnodescache(object): repo = self._repo try: - lock = repo.wlock(wait=False) + lock = repo.lock(wait=False) except error.LockError: repo.ui.log( b'tagscache', diff --git a/tests/test-tags.t b/tests/test-tags.t --- a/tests/test-tags.t +++ b/tests/test-tags.t @@ -156,7 +156,7 @@ Tag cache debug info written to blackbox Failure to acquire lock results in no write $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1 - $ echo 'foo:1' > .hg/wlock + $ echo 'foo:1' > .hg/store/lock $ hg identify b9154636be93 tip $ hg blackbox -l 6 @@ -170,7 +170,7 @@ Failure to acquire lock results in no wr $ fnodescacheexists no fnodes cache - $ rm .hg/wlock + $ rm .hg/store/lock $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1 $ hg identify