Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running incoming and outgoing commands in parallel isn’t always supported #187

Open
palant opened this issue May 31, 2022 · 0 comments
Open

Comments

@palant
Copy link

palant commented May 31, 2022

This code will run hg incoming and hg outgoing in parallel which is problematic:

vscode-hg/src/repository.ts

Lines 1134 to 1143 in 923f511

await Promise.all([
this.countIncomingAfterDelay(
expectedDeltas && expectedDeltas.incoming,
delayMillis
),
this.countOutgoingAfterDelay(
expectedDeltas && expectedDeltas.outgoing,
delayMillis
),
]);

I have hg-git extension installed which locks the repository for these commands. Consequently, running them in parallel results in an error:

Traceback (most recent call last):
  File "/usr/lib64/python3.10/site-packages/dulwich/file.py", line 150, in __init__
    fd = os.open(
FileExistsError: [Errno 17] File exists: b'repo/.hg/git/refs/heads/main.lock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/hg", line 61, in <module>
    dispatch.run()
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 144, in run
    status = dispatch(req)
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 250, in dispatch
    status = _rundispatch(req)
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 294, in _rundispatch
    ret = _runcatch(req) or 0
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 470, in _runcatch
    return _callcatch(ui, _runcatchfunc)
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 480, in _callcatch
    return scmutil.callcatch(ui, func)
  File "/usr/lib64/python3.10/site-packages/mercurial/scmutil.py", line 153, in callcatch
    return func()
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 460, in _runcatchfunc
    return _dispatch(req)
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 1273, in _dispatch
    return runcommand(
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 918, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 1285, in _runcommand
    return cmdfunc()
  File "/usr/lib64/python3.10/site-packages/mercurial/dispatch.py", line 1271, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/usr/lib64/python3.10/site-packages/mercurial/util.py", line 1887, in check
    return func(*args, **kwargs)
  File "/usr/lib64/python3.10/site-packages/mercurial/commands.py", line 5022, in outgoing
    return hg.outgoing(ui, repo, dests, opts)
  File "/usr/lib64/python3.10/site-packages/mercurial/hg.py", line 1433, in outgoing
    o, others = _outgoing(ui, repo, dests, opts, subpath=subpath)
  File "/usr/lib64/python3.10/site-packages/mercurial/hg.py", line 1379, in _outgoing
    outgoing = discovery.findcommonoutgoing(
  File "hg-git/hggit/gitrepo.py", line 152, in findcommonoutgoing
    heads = repo.githandler.get_refs(other.path)[0]
  File "hg-git/hggit/git_handler.py", line 437, in get_refs
    exportable = self.export_commits()
  File "hg-git/hggit/git_handler.py", line 432, in export_commits
    return self.update_references()
  File "hg-git/hggit/git_handler.py", line 1639, in update_references
    self.git.refs[git_ref] = git_sha
  File "/usr/lib64/python3.10/site-packages/dulwich/refs.py", line 377, in __setitem__
    self.set_if_equals(name, None, ref)
  File "/usr/lib64/python3.10/site-packages/dulwich/refs.py", line 931, in set_if_equals
    with GitFile(filename, "wb") as f:
  File "/usr/lib64/python3.10/site-packages/dulwich/file.py", line 92, in GitFile
    return _GitFile(filename, mode, bufsize, mask)
  File "/usr/lib64/python3.10/site-packages/dulwich/file.py", line 156, in __init__
    raise FileLocked(filename, self._lockfilename)
dulwich.file.FileLocked: (b'repo/.hg/git/refs/heads/main', b'repo/.hg/git/refs/heads/main.lock')

Maybe drop Promise.all() here and run the commands sequentially?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant