Page MenuHomePhorge

Wrong time limit in `repository pull`
Open, Needs TriagePublic

Description

(This task is the result of the Ponder Question Q52: How to set the Pull Time Limit for Mercurial repos?)

When running bin/repository pull … (whether manually or started from a task), a time limit of - by default - 15 minutes is applied. This time limit was probably only meant for special cases (git repositories in conjunction with Drydock), but now affects all repositories, and even initial checkouts. Because the setting was only intended for git repositories, it also can only be configured for git repositories, breaking imports of large Mercurial repos (which do not finish within 15 minutes)

Details

I currently cannot import a large Mercurial repository. The error I see is:

[2023-04-26 06:14:15] EXCEPTION: (Exception) Command failed with error #255!
COMMAND
hg --config ui.ssh=/var/www/phorge/phorge/bin/ssh-connect pull -- '********'

STDOUT
pulling from https://<redacted>


STDERR
waiting for lock on working directory of /var/repo/8 held by process '112297' on host 'ec6149cd0a0b/f000037a'
abort: working directory of /var/repo/8: timed out waiting for lock held by 'ec6149cd0a0b/f000037a:112297'
 at [<phorge>/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php:740]
arcanist(head=ca5f5cd1522c712f4bdb890ad49e993a9b51417c, ref.master=ca5f5cd1522c), phorge(head=1ba5c8c260950ce8bc77f261b41aa82ad5d776e2, ref.master=90f9da643d16)
  #0 PhabricatorRepositoryPullEngine::executeMercurialUpdate() called at [<phorge>/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php:134]
  #1 PhabricatorRepositoryPullEngine::pullRepositoryWithLock() called at [<phorge>/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php:40]
  #2 PhabricatorRepositoryPullEngine::pullRepository() called at [<phorge>/src/applications/repository/management/PhabricatorRepositoryManagementPullWorkflow.php:50]
  #3 PhabricatorRepositoryManagementPullWorkflow::execute(PhutilArgumentParser) called at [<arcanist>/src/parser/argument/PhutilArgumentParser.php:492]
  #4 PhutilArgumentParser::parseWorkflowsFull(array) called at [<arcanist>/src/parser/argument/PhutilArgumentParser.php:377]
  #5 PhutilArgumentParser::parseWorkflows(array) called at [<phorge>/scripts/repository/manage_repositories.php:22]

The relevant timeout is applied inside a future that is buit inside executeMercurialUpdate(…), which calls $repository->getRemoteCommandFuture(), which boils down to the call newRemoteCommandEngine(…)->newFuture(); in the repo base class. The newRemoteCommandEngine() calls returns a DiffusionCommandEngine, which uses getEffectiveCopyTimeLimit() in the newFuture() method.

This timeout is controlled via the limit.copy detail attached to the repo, which can only be edited for git repositories.

According to @avivey 's answer to Q52: How to set the Pull Time Limit for Mercurial repos?, this timeout was never indended for "arbitrary pulls", but only for special cases. For the initial checkout, there is a separate 4h timeout configured. However, the task limited by this 4h-timeout basically just runs bin/repo pull …, and therefore is also affected by the 15m timeout.

The solution would probably be (according to @avivey ) to make sure the 15m timeout only affects the pulls in the intended setting (git repositories and Drydock).