sapling icon indicating copy to clipboard operation
sapling copied to clipboard

"Too many open files" while histedit'ing and rolling 14 commits into one

Open francois opened this issue 2 years ago • 2 comments

I have a stack with 14 commits: a main commit, then 13 WIP commits. These were done as part of an Ensemble Programming session, hence they didn't have useful commit messages, on purpose.

Now, it is time to take that stack and make it more useful. The first operation I tried was to roll every commit into the original one.

The stack, pre-histedit:

╰─○ sl
  @  7877f6d49  2 minutes ago  emmanuel
  │  WIP
  │
  o  0107f7991  2 minutes ago  emmanuel
  │  WIP
  │
  o  dd9827501  2 minutes ago  francois
  │  WIP
  │
  o  f634044f0  2 minutes ago  emmanuel
  │  WIP
  │
  o  d25bbec28  2 minutes ago  francois
  │  WIP
  │
  o  e0a0f9c7f  2 minutes ago  francois
  │  WIP
  │
  o  b2485b9d5  2 minutes ago  emmanuel
  │  WIP
  │
  o  2e31352e9  2 minutes ago  francois
  │  WIP
  │
  o  628655aa6  2 minutes ago  francois
  │  WIP
  │
  o  00a282d5c  2 minutes ago  denis
  │  WIP
  │
  o  6f99ad773  2 minutes ago  emmanuel
  │  WIP
  │
  o  3e9d70ac3  2 minutes ago  francois
  │  WIP
  │
  o  1bdc3801f  2 minutes ago  francois
  │  WIP
  │
  o  768e1936e  2 minutes ago  francois  #981
╭─╯  GA9-113: Implement BundleGenerator

The stack has been rebased against main, hence the recent commit timestamps.

When I histedit'd, this is what I ended up with right before saving:

pick 768e1936e082 GA9-113: Implement BundleGenerator
r 1bdc3801f400 WIP
r 3e9d70ac325c WIP
r 6f99ad7730cc WIP
r 00a282d5cd64 WIP
r 628655aa6b50 WIP
r 2e31352e9300 WIP
r b2485b9d548e WIP
r e0a0f9c7f10e WIP
r d25bbec28ac7 WIP
r f634044f04d1 WIP
r dd9827501c53 WIP
r 0107f7991275 WIP
r 7877f6d49039 WIP

When I save and exit my editor, I get a small pause, then a progress bar starting at "5/14", then a crash with the following traceback:

╰─○ sl histedit
** Sapling SCM (version 0.2.20230124-180750) has crashed:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/__init__.py", line 106, in run
    dispatch.run(args, fin, fout, ferr, config)
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 161, in run
    status = (dispatch(req) or 0) & 255
              ^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 503, in dispatch
    ret = _runcatch(req)
          ^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 712, in _runcatch
    return _callcatch(ui, req, _runcatchfunc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 721, in _callcatch
    return scmutil.callcatch(ui, req, func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/scmutil.py", line 147, in callcatch
    return func()
           ^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 683, in _runcatchfunc
    return _dispatch(req)
           ^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 1218, in _dispatch
    ret = runcommand(
          ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/undo.py", line 146, in _runcommandwrapper
    result = orig(lui, repo, cmd, fullargs, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/journal.py", line 80, in runcommand
    return orig(lui, repo, cmd, fullargs, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/sparse.py", line 504, in _tracktelemetry
    res = runcommand(lui, repo, *args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/copytrace.py", line 164, in _runcommand
    return orig(lui, repo, cmd, fullargs, ui, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 913, in runcommand
    ret = _runcommand(ui, options, cmd, d)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 1259, in _runcommand
    return cmdfunc()
           ^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/dispatch.py", line 1217, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/util.py", line 1295, in check
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/util.py", line 1295, in check
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/remotenames.py", line 408, in exhistedit
    ret = orig(ui, repo, *args, **opts)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/util.py", line 1295, in check
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/histedit.py", line 1094, in histedit
    _histedit(ui, repo, state, *freeargs, **opts)
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/fbhistedit.py", line 295, in _histedit
    return orig(ui, repo, state, *freeargs, **opts)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/histedit.py", line 1176, in _histedit
    _continuehistedit(ui, repo, state)
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/histedit.py", line 1218, in _continuehistedit
    parentctx, replacement_ = actobj.run()
                              ^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/histedit.py", line 547, in run
    self.applychange()
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/ext/histedit.py", line 557, in applychange
    with repo.wlock(), repo.lock(), repo.transaction("histedit"):
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/util.py", line 673, in __exit__
    self.close()
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/transaction.py", line 70, in _active
    return func(self, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/transaction.py", line 546, in close
    self.validator(self)  # will raise exception if needed
    ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/localrepo.py", line 1765, in validate
    _flushchangelog(repo)
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/edenscm/localrepo.py", line 1801, in _flushchangelog
    cl.inner.flush(mainnodes)
error.RustError: "/Users/francois/Projects/marketplace/.sl/store/segments/v1/idmap2/index2-group-name": cannot duplicate
in Log:try_clone
  Log.dir = SharedMeta { path: Filesystem("/Users/francois/Projects/marketplace/.sl/store/segments/v1/idmap2"), meta: Mutex { data: LogMetadata { primary_len: 250262, indexes: {"2-group-name": 221553, "2-id": 106588}, epoch: 2459506669661666743 }, poisoned: false, .. } }
Caused by 1 errors:
- Too many open files (os error 24)

OS Info:

╰─○ sl --version
Sapling 0.2.20230124-180750
╰─○ ulimit -n
256

MacBook Pro 14", 32 GiB RAM, Ventura 13.2.1.

In the end, I was able to histedit by rolling commits from the bottom of the stack: first, I rolled 7877f6d49039 into 0107f7991275, then I rolled the last two commits into the previous one, and so on. At one point, I was able to roll 5 commits in one operation.

francois avatar Feb 27 '23 17:02 francois

Can you try increasing your ulimit to 1048576 as described here?

sggutier avatar Mar 07 '23 00:03 sggutier

I have a similar problem, simply rebasing a branch onto another. Increasing the ulimit did fix the problem. However I was wondering if this is not an indication of some deeper issue with sapling, given the same rebase in git works without any issue. Is there any plan to reduce the requirements in terms of open file descriptors limit?

ktf avatar Oct 19 '23 10:10 ktf