[Bug 5584] New: dirstate fixup behavior isn't race safe with other update calls

mercurial-bugs at mercurial-scm.org mercurial-bugs at mercurial-scm.org
Thu Jun 1 22:20:30 UTC 2017


https://bz.mercurial-scm.org/show_bug.cgi?id=5584

            Bug ID: 5584
           Summary: dirstate fixup behavior isn't race safe with other
                    update calls
           Product: Mercurial
           Version: default branch
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: bug
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla at mercurial-scm.org
          Reporter: sid0 at fb.com
                CC: mercurial-devel at mercurial-scm.org

Today, we write out the dirstate whenever we want to mark some files in the
lookup set as clean. This isn't safe: it doesn't account for if a dirstate
change happens underneath.

Demonstration:

  $ hg init repo
  $ cd repo
  $ echo a > a
  $ hg add a
  $ hg commit -m test

  $ echo test > b
  $ hg add b
  $ hg commit -m test2

  $ cat >> $TESTTMP/dirstaterace.py << EOF
  > from mercurial import (
  >     context,
  >     extensions,
  > )
  > def extsetup():
  >     extensions.wrapfunction(context.workingctx, '_checklookup',
overridechecklookup)
  > def overridechecklookup(orig, self, files):
  >     # make an update that changes the dirstate from underneath
  >     self._repo.ui.system('hg --cwd=$TESTTMP/repo update .^')
  >     return orig(self, files)
  > EOF

  $ hg up null
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hg up 1
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg debugdirstate
  n 644          2 unset               a
  n 644          5 unset               b
  $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py

The last status fails with:

  abort: No such file or directory: '$TESTTMP/repo/b'

which is really a symptom of the real problem: that two concurrent dirstate
modifications can trample over each other.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list