phacility/phabricator · error · Exception
Trying to activate a lease on a pending resource.
Error message
Trying to activate a lease on a pending resource.
What it means
Activation gives a lease a live interface, which is only meaningful once the underlying resource has finished starting up; activating against a resource still in STATUS_PENDING is refused (the code even carries a TODO about being stricter). Unlike the wrong-lease-status variants, this condition is often transient: the resource will typically move PENDING → ACTIVE via its update worker, after which activation succeeds. The stock lease worker yields and retries in this situation.
Source
Thrown at src/applications/drydock/storage/DrydockLease.php:343
public function isAcquiredLease() {
return $this->isAcquired;
}
public function activateOnResource(DrydockResource $resource) {
$expect_status = DrydockLeaseStatus::STATUS_ACQUIRED;
$actual_status = $this->getStatus();
if ($actual_status != $expect_status) {
throw new Exception(
pht(
'Trying to activate a lease which has the wrong status: status '.
'must be "%s", actually "%s".',
$expect_status,
$actual_status));
}
if ($resource->getStatus() == DrydockResourceStatus::STATUS_PENDING) {
// TODO: Be stricter about this?
throw new Exception(
pht(
'Trying to activate a lease on a pending resource.'));
}
$this->openTransaction();
try {
DrydockSlotLock::acquireLocks($this->getPHID(), $this->slotLocks);
$this->slotLocks = array();
} catch (DrydockSlotLockException $ex) {
$this->killTransaction();
$this->logEvent(
DrydockSlotLockFailureLogType::LOGCONST,
array(
'locks' => $ex->getLockMap(),
));
View on GitHub (pinned to 5720a38cfe)
Solutions
- Wait for the resource to reach STATUS_ACTIVE (poll its status or let the lease update worker retry) before activating the lease
- Trigger the resource's update worker (`./bin/drydock update-resource --id <n>`) to force it through pending
- Check the resource log/blueprint log for why provisioning is stalled in PENDING — that is the real problem when the wait never ends
- If the resource is permanently pending due to a blueprint failure, release the lease and resource and re-allocate
Example fix
// before
$lease->activateOnResource($resource); // resource still STATUS_PENDING
// Exception: Trying to activate a lease on a pending resource.
// after
$resource = $resource->reload();
while ($resource->getStatus() === DrydockResourceStatus::STATUS_PENDING) {
sleep(5); // or yield the worker task and retry later
$resource = $resource->reload();
}
$lease->activateOnResource($resource); Defensive patterns
Strategy: retry
Validate before calling
// Before activating, confirm the resource has finished starting up:
$resource = $resource->reload();
if ($resource->getStatus() === DrydockResourceStatus::STATUS_PENDING) {
// not ready yet: schedule retry / trigger the resource update worker
throw new PhabricatorWorkerYieldException(15);
}
$lease->activateOnResource($resource); Try / catch
catch (Exception $ex) { on 'pending resource', catch DrydockResourceLockException-style yielding: wait for the resource update worker to move it to ACTIVE, then retry activation with freshly loaded objects } Prevention
- Treat resource startup as asynchronous: poll status or yield/retry, never assume immediate readiness
- Force a stalled resource through its update with ./bin/drydock update-resource --id <n>
- Alert on resources stuck in PENDING — a lease failing here is usually a symptom of a stuck blueprint, not a lease bug
When it happens
Trigger: Two-phase leases (acquire then activate) where activation runs before the resource's boot/provisioning completes; host blueprints with slow startup; queuing activation immediately after acquiring on a resource allocated moments earlier.
Common situations: Working-copy leases on freshly allocated hosts; build queues that try to activate leases during infrastructure cold-start; tests that skip waiting for resource activation.
Related errors
- Trying to acquire an active lease on a pending resource. You
- Trying to acquire lease ("%s") on a resource ("%s") in the w
- Trying to activate a lease which has the wrong status: statu
- Working copy lease is missing required attribute "%s". Attr
- Use "--lease" to specify a lease.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/3a3e0483ea190ffb.
Report an issue: GitHub.