Page MenuHomePhabricator

Transaction publishing may stall during mail expansion of package recipients
Closed, ResolvedPublic

Description

Caught this stuck in the daemon queue on secure:

$ /core/lib/phabricator/bin/worker execute --id 22218543
 EXECUTE  Executing Task 22218543 (PhabricatorApplicationTransactionPublishWorker)...
[2021-03-27 14:55:42] EXCEPTION: (RuntimeException) Undefined index: PHID-OPKG-mvkqudcgslb7dysivu3z at [<arcanist>/src/error/PhutilErrorHandler.php:252]
arcanist(head=master, ref.master=f0f95e5b2612), libcore(), phabricator(head=master, ref.master=61272e7ac31a, custom=1), secure(head=master, ref.master=988cf9bd7958), services(head=master, ref.master=0f2518e7c8f9)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phabricator>/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php:302]
  #1 PhabricatorMailReplyHandler::expandRecipientPHIDs(array, array) called at [<phabricator>/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php:207]
  #2 PhabricatorMailReplyHandler::getMailTargets(array, array) called at [<phabricator>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:3068]
  #3 PhabricatorApplicationTransactionEditor::buildMailWithRecipients(DifferentialRevision, array, array, array, array) called at [<phabricator>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:3052]
  #4 PhabricatorApplicationTransactionEditor::buildMail(DifferentialRevision, array) called at [<phabricator>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:1494]
  #5 PhabricatorApplicationTransactionEditor::publishTransactions(DifferentialRevision, array) called at [<phabricator>/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php:21]
  #6 PhabricatorApplicationTransactionPublishWorker::doWork() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:124]
  #7 PhabricatorWorker::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php:160]
  #8 PhabricatorWorkerActiveTask::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php:97]
  #9 PhabricatorWorkerManagementExecuteWorkflow::execute(PhutilArgumentParser) called at [<arcanist>/src/parser/argument/PhutilArgumentParser.php:492]
  #10 PhutilArgumentParser::parseWorkflowsFull(array) called at [<arcanist>/src/parser/argument/PhutilArgumentParser.php:377]
  #11 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/setup/manage_worker.php:21]

Event Timeline

epriestley triaged this task as Wishlist priority.Mar 27 2021, 2:57 PM
epriestley created this task.

This happens when a recipient list includes an Owners package which has been destroyed. Specifically, we'll exit this section of PhabricatorMetaMTAMemberQuery with out the PHID in $package_map, and then fail to return it:

PhabricatorMetaMTAMemberQuery.php:46
$package_map = array();
if ($package_phids) {
  $packages = id(new PhabricatorOwnersPackageQuery())
    ->setViewer($viewer)
    ->withPHIDs($package_phids)
    ->execute();

  foreach ($packages as $package) {
    $package_owners = array();
    foreach ($package->getOwners() as $owner) {
      $owner_phid = $owner->getUserPHID();
      $owner_type = phid_get_type($owner_phid);
      $type_map[$owner_type][] = $owner_phid;
      $package_owners[] = $owner_phid;
    }
    $package_map[$package->getPHID()] = $package_owners;
  }
}

The remedy is to guarantee that all PHIDs in $package_phids are present in $package_map, but with a value of array() if they fail to load.

The stalled transactions on this host published after I deployed the update.