changeset 45435:64de86fd0984

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
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 08 Sep 2020 19:36:40 +0530
parents 5523e3e1bc71
children 1b3197047f5c
files mercurial/tags.py tests/test-tags.t
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/tags.py	Thu Sep 10 13:37:35 2020 +0530
+++ b/mercurial/tags.py	Tue Sep 08 19:36:40 2020 +0530
@@ -838,7 +838,7 @@
         repo = self._repo
 
         try:
-            lock = repo.wlock(wait=False)
+            lock = repo.lock(wait=False)
         except error.LockError:
             repo.ui.log(
                 b'tagscache',
--- a/tests/test-tags.t	Thu Sep 10 13:37:35 2020 +0530
+++ b/tests/test-tags.t	Tue Sep 08 19:36:40 2020 +0530
@@ -156,7 +156,7 @@
 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 @@
   $ fnodescacheexists
   no fnodes cache
 
-  $ rm .hg/wlock
+  $ rm .hg/store/lock
 
   $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
   $ hg identify