How to deal with repeated "Duplicate entry" errors during repository importing?

We’ve been trying to import a repo that is more or less a mirror of the Linux kernel repository but we’ve been receiving error messages like this when we run phd log:

Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000] [2020-01-20 11:30:55] EXCEPTION: (PhutilProxyException) Error while executing Task ID 52837761. {>} (AphrontDuplicateKeyQueryException) #1062: Duplicate entry '2031545-172202' for key 'PRIMARY' at [<phabricator>/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:345]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000] arcanist(), phabricator(), phutil()
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #0 <#2> AphrontBaseMySQLDatabaseConnection::throwCommonException(integer, string) called at [<phabricator>/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:379]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #1 <#2> AphrontBaseMySQLDatabaseConnection::throwQueryCodeException(integer, string) called at [<phabricator>/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:320]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #2 <#2> AphrontBaseMySQLDatabaseConnection::throwQueryException(mysqli) called at [<phabricator>/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:216]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #3 <#2> AphrontBaseMySQLDatabaseConnection::executeQuery(PhutilQueryString) called at [<phabricator>/src/infrastructure/storage/xsprintf/queryfx.php:8]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #4 <#2> queryfx(AphrontMySQLiDatabaseConnection, string, string, array) called at [<phabricator>/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php:152]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #5 <#2> PhabricatorRepositoryCommitChangeParserWorker::writeCommitChanges(PhabricatorRepository, PhabricatorRepositoryCommit, array) called at [<phabricator>/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php:38]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #6 <#2> PhabricatorRepositoryCommitChangeParserWorker::parseCommit(PhabricatorRepository, PhabricatorRepositoryCommit) called at [<phabricator>/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php:51]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #7 <#2> PhabricatorRepositoryCommitParserWorker::doWork() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:124]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #8 <#2> PhabricatorWorker::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php:158]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #9 <#2> PhabricatorWorkerActiveTask::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php:22]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #10 PhabricatorTaskmasterDaemon::run() called at [<phutil>/src/daemon/PhutilDaemon.php:219]
Daemon 74154 STDE [Mon, 20 Jan 2020 11:30:55 +0000]   #11 PhutilDaemon::execute() called at [<phutil>/scripts/daemon/exec/exec_daemon.php:131]

We have another repo with a different name/callsign that is also a Linux repository mirror and is already fully imported but I don’t know if this has any bearing on what we’re seeing.

As new commits are being parsed they keep triggering errors similar to this one. We’ve deactivated the repository but Phabricator is still churning through the pre-existing queue of commits to import. I’ve got a few questions (which might have answers like “That’s just how it is” or “No”) but any hints will be gratefully accepted:

  1. Is there a way to know why the key was already present in the database?
  2. Is there an easy way to track a task to a specific repo? I’ve been doing it by following links from the daemon web page but not all tasks have a Data field with a link that can be followed.
  3. I’ve tried cancelling workers (via ./worker cancel --id <taskid>) so are there next steps to try and “repair” the import or is the current one unsalvageable?
  4. Is there a way to delete items from the queue of commits to be parsed (as in the list we see when we do ./repository importing rREPONAME)?
  5. Similar to the above, if this happens again is there a safe way to just stop the import entirely?
  6. Is it safe to destroy the repo (via remove destroy rREPONAME) and try recreating/reimporting it?

We’re using Phabricator repos from stable branches as of 2019-11-27 :
Phabricator 959504a4881cc238d81208244e6801b9afb087ca
arcanist cc850163f30c4697e925df0d6212469679600a2c
libphutil 39ed96cd818aae761ec92613a9ba0800824d0ab0