phacility/phabricator · error · PhabricatorWorkerPermanentFailureException

Lease "%s" could not be loaded.

Error message

Lease "%s" could not be loaded.

What it means

DrydockRepositoryOperationUpdateWorker remembers the working-copy lease PHID in the operation property 'exec.leasePHID'. On later runs it loads that lease; if the query (with the daemons' omnipotent viewer) cannot find it, the operation fails permanently. The lease was deleted or is in a state where it no longer exists, so the operation can never continue.

Source

Thrown at src/applications/drydock/worker/DrydockRepositoryOperationUpdateWorker.php:102

  private function loadWorkingCopyLease(
    DrydockRepositoryOperation $operation) {
    $viewer = $this->getViewer();

    // TODO: This is very similar to leasing in Harbormaster, maybe we can
    // share some of the logic?

    $working_copy = new DrydockWorkingCopyBlueprintImplementation();
    $working_copy_type = $working_copy->getType();

    $lease_phid = $operation->getProperty('exec.leasePHID');
    if ($lease_phid) {
      $lease = id(new DrydockLeaseQuery())
        ->setViewer($viewer)
        ->withPHIDs(array($lease_phid))
        ->executeOne();
      if (!$lease) {
        throw new PhabricatorWorkerPermanentFailureException(
          pht(
            'Lease "%s" could not be loaded.',
            $lease_phid));
      }
    } else {
      $repository = $operation->getRepository();

      $allowed_phids = $repository->getAutomationBlueprintPHIDs();
      $authorizing_phid = $repository->getPHID();

      $lease = DrydockLease::initializeNewLease()
        ->setResourceType($working_copy_type)
        ->setOwnerPHID($operation->getPHID())
        ->setAuthorizingPHID($authorizing_phid)
        ->setAllowedBlueprintPHIDs($allowed_phids);

      $map = $this->buildRepositoryMap($operation);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Verify the lease PHID still exists: query DrydockLease by PHID or check the Drydock lease UI.
  2. If the lease is gone, re-run or restart the repository operation so it allocates a fresh lease.
  3. Prevent premature lease destruction: keep the operation worker running and avoid reclaiming leases that belong to active operations.
Defensive patterns

Strategy: validation

Validate before calling

$lease = id(new DrydockLeaseQuery())
  ->setViewer(PhabricatorUser::getOmnipotentUser())
  ->withPHIDs(array($operation->getProperty('exec.leasePHID')))
  ->executeOne();
if (!$lease) {
  // clear the stale property and let the operation allocate a fresh lease
  $operation->setProperty('exec.leasePHID', null)->save();
}

Prevention

When it happens

Trigger: The operation's lease was destroyed between worker runs (lease expiry, reclamation, manual destroy); the property points at a PHID from another install (database restore or copy); the lease row was removed directly.

Common situations: Long-running repository operations (merge, land) whose lease is garbage-collected; restoring a Phabricator database without the matching Drydock rows; aggressive lease reclamation settings.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/9cec1c676a6abf87. Report an issue: GitHub.