Patchwork [2,of,2] tags: take lock instead of wlock before writing hgtagsfnodes1 cache

login
register
mail settings
Submitter Pulkit Goyal
Date Sept. 10, 2020, 6:13 a.m.
Message ID <72038a47c1cd157672f4.1599718428@workspace>
Download mbox | patch
Permalink /patch/47118/
State Superseded
Headers show

Comments

Pulkit Goyal - Sept. 10, 2020, 6:13 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1599574000 -19800
#      Tue Sep 08 19:36:40 2020 +0530
# Node ID 72038a47c1cd157672f44e33c839c7823989cee4
# Parent  5ecbecdc0aa49eb6a3878e01f8aa99417602b957
# EXP-Topic tags-fix
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

Patch

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',