How to fix/mitigate unreachable commits in git repo when using ./bin/repository reparse

I am trying to ensure that all repos have properly had all their commits parsed after doing a BIG Phabricator upgrade (1y+). It seemed like I should run the repository reparse command to do so. Unfortunately, it hits any sort of unreachable commit and bails. Is there a way to remove these unreachable commits or make the reparse skip them? Versions & output log below:

phabricator fc49428c43ce6d6ab3ecdf6c753e90110de5a9fd (Fri, Jun 14) (branched from 
            683647f1fb9091b8928056d068be7bb954c127c9 on upstream) 
arcanist    36a397de12d07ad2093f2299c418a178502d1747 (Thu, Jun 13) (branched from 
            2234c8cacc21ce61c9c10e8e5918b6a63cc38fc8 on upstream) 
phutil      1fcc3a2d3799581453584c90d621329a7ed5c00d (Tue, Jun 11) (branched from 
            e4f8b70e73faff0edeb3a310c0ff1d10b4b54949 on upstream) 
php         5.4.16 
diff        3.3 at /bin/diff 
git         2.15.1 at /bin/git
$ ./bin/repository reparse --all rG --importing
[2019-06-17 15:18:12] EXCEPTION: (PhabricatorWorkerPermanentFailureException) Commit "rG5fedbbc36e5a2a90a9c1e03cf2b25056fea1fc0c" (with internal ID "582402") is no longer reachable from any branch, tag, or ref in this repository, so it will not be imported. This usually means that the branch the commit was on was deleted or overwritten. at [<phabricator>/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php:30]
arcanist(head=staging/master, ref.master=7e3dda70f805, ref.staging/master=36a397de12d0), phabricator(head=staging/master, ref.master=2b4c650923ed, ref.staging/master=fc49428c43ce), phutil(head=staging/master, ref.master=e87f63753d86, ref.staging/master=1fcc3a2d3799)
  #0 PhabricatorRepositoryCommitParserWorker::loadCommit() called at [<phabricator>/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php:46]
  #1 PhabricatorRepositoryCommitParserWorker::doWork() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:124]
  #2 PhabricatorWorker::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:163]
  #3 PhabricatorWorker::scheduleTask(string, array, array) called at [<phabricator>/src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php:260]
  #4 PhabricatorRepositoryManagementReparseWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:457]
  #5 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:349]
  #6 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/repository/manage_repositories.php:22]

This is a bug. bin/repository reparse should continue when it encounters a PhabricatorWorkerPermanentFailureException.

A likely workaround is to use the --background flag, but I expect to fix this in the upstream shortly.

This is now upstream as https://secure.phabricator.com/T13315.

This should be resolved by https://secure.phabricator.com/D20588.

Thanks for the report!

Thanks very much, cherry-picked the fix to our branch and confirmed it works!