phacility/phabricator · error · Exception

Trying to activate lease with no resource.

Error message

Trying to activate lease with no resource.

What it means

DrydockLeaseUpdateWorker::activateLease() loads the lease's resource with getResource() and immediately refuses if it is null. A lease in the activation phase must point at a resource row; a null means the lease has no resource PHID set or the referenced resource was deleted. This usually signals data loss or a lease that reached activation without completing acquisition.

Source

Thrown at src/applications/drydock/worker/DrydockLeaseUpdateWorker.php:979

          'Blueprint "%s" (of type "%s") is not properly implemented: it '.
          'returned from "%s" with a lease acquired on the wrong resource.',
          $blueprint->getBlueprintName(),
          $blueprint->getClassName(),
          'acquireLease()'));
    }
  }


/* -(  Activating Leases  )-------------------------------------------------- */


  /**
   * @task activate
   */
  private function activateLease(DrydockLease $lease) {
    $resource = $lease->getResource();
    if (!$resource) {
      throw new Exception(
        pht('Trying to activate lease with no resource.'));
    }

    $resource_status = $resource->getStatus();

    if ($resource_status == DrydockResourceStatus::STATUS_PENDING) {
      throw new PhabricatorWorkerYieldException(15);
    }

    if ($resource_status != DrydockResourceStatus::STATUS_ACTIVE) {
      throw new DrydockAcquiredBrokenResourceException(
        pht(
          'Trying to activate lease ("%s") on a resource ("%s") in '.
          'the wrong status ("%s").',
          $lease->getPHID(),
          $resource->getPHID(),
          $resource_status));
    }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Check the lease's resourcePHID and the existence of that resource before queueing activation work.
  2. If the resource is gone, release or destroy the lease explicitly instead of letting the activation task fail.
  3. Investigate why the lease reached activation without a live resource (look at the lease and resource event logs).

Example fix

// before
$lease->waitUntilActive();

// after
$resource = $lease->getResource();
if ($resource === null) {
  $lease->setStatus(DrydockLeaseStatus::STATUS_RELEASED)->save();
  throw new Exception(pht('Lease "%s" lost its resource.', $lease->getPHID()));
}
Defensive patterns

Strategy: validation

Validate before calling

if (!$lease->getResourcePHID() || !$lease->getResource()) {
  // do not queue activation for a lease with no live resource
  throw new Exception(pht('Lease "%s" has no resource.', $lease->getPHID()));
}

Prevention

When it happens

Trigger: The resource was destroyed between acquire and activate and the load now returns null; a lease row whose resourcePHID is empty because acquisition half-completed; manual database edits or a crash between the acquire and the lease update task.

Common situations: Aggressive resource reclamation destroying resources under pending leases; race between resource destroy and lease activation workers; restoring a database dump inconsistently.

Related errors


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