phacility/phabricator · error · Exception

Failed to load repository cluster service.

Error message

Failed to load repository cluster service.

What it means

synchronizeWorkingCopyAfterCreation() runs right after a repository is created inside a cluster: it must seed working-copy version rows (version 0) for every device bound to the repository's Almanac service. loadAlmanacService() returned null, meaning the repository references a cluster service that cannot be loaded, so the engine has no bindings to initialize and aborts.

Source

Thrown at src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php:88

   * Synchronize repository version information after creating a repository.
   *
   * This initializes working copy versions for all currently bound devices to
   * 0, so that we don't get stuck making an ambiguous choice about which
   * devices are leaders when we later synchronize before a read.
   *
   * @task sync
   */
  public function synchronizeWorkingCopyAfterCreation() {
    if (!$this->shouldEnableSynchronization(false)) {
      return;
    }

    $repository = $this->getRepository();
    $repository_phid = $repository->getPHID();

    $service = $repository->loadAlmanacService();
    if (!$service) {
      throw new Exception(pht('Failed to load repository cluster service.'));
    }

    $bindings = $service->getActiveBindings();
    foreach ($bindings as $binding) {
      PhabricatorRepositoryWorkingCopyVersion::updateVersion(
        $repository_phid,
        $binding->getDevicePHID(),
        0);
    }

    return $this;
  }


  /**
   * @task sync
   */
  public function synchronizeWorkingCopyAfterHostingChange() {

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Open the repository, go to Manage, then Cluster, and identify which Almanac service it references; open that service in the Almanac console
  2. Either restore/recreate a repository-type Almanac service with the correct device bindings and point the repository at it, or clear the cluster assignment so the repository is standalone
  3. Confirm the service type is 'repository': the name alone is not enough
Defensive patterns

Strategy: validation

Validate before calling

$service = $repository->loadAlmanacService();
if ($service === null) {
  // refuse to start cluster sync; surface a configuration error to the operator
}

Type guard

function hasLoadableClusterService(PhabricatorRepository $repo) {
  return $repo->loadAlmanacService() !== null;
}

Try / catch

try {
  $engine->synchronizeWorkingCopyAfterCreation();
} catch (Exception $ex) {
  // fail the creation job visibly; do not mark the repository healthy while the service is unresolvable
}

Prevention

When it happens

Trigger: Creating a repository (or its daemons first picking it up) while the repository's Cluster service PHID points at a deleted, recreated, or unresolvable Almanac service, or at a service that is not a repository-type service.

Common situations: The Almanac repository service was deleted without first un-clustering its repositories; the service was recreated so its PHID changed; a database import/restore left repositories with a stale servicePHID.

Related errors


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