{"record":{"id":"a7b8c0f2771bb51a","repo":"phacility/phabricator","slug":"failed-to-load-repository-cluster-service","errorCode":null,"errorMessage":"Failed to load repository cluster service.","messagePattern":"Failed to load repository cluster service\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php","lineNumber":88,"sourceCode":"   * Synchronize repository version information after creating a repository.\n   *\n   * This initializes working copy versions for all currently bound devices to\n   * 0, so that we don't get stuck making an ambiguous choice about which\n   * devices are leaders when we later synchronize before a read.\n   *\n   * @task sync\n   */\n  public function synchronizeWorkingCopyAfterCreation() {\n    if (!$this->shouldEnableSynchronization(false)) {\n      return;\n    }\n\n    $repository = $this->getRepository();\n    $repository_phid = $repository->getPHID();\n\n    $service = $repository->loadAlmanacService();\n    if (!$service) {\n      throw new Exception(pht('Failed to load repository cluster service.'));\n    }\n\n    $bindings = $service->getActiveBindings();\n    foreach ($bindings as $binding) {\n      PhabricatorRepositoryWorkingCopyVersion::updateVersion(\n        $repository_phid,\n        $binding->getDevicePHID(),\n        0);\n    }\n\n    return $this;\n  }\n\n\n  /**\n   * @task sync\n   */\n  public function synchronizeWorkingCopyAfterHostingChange() {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open the repository, go to Manage, then Cluster, and identify which Almanac service it references; open that service in the Almanac console","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","Confirm the service type is 'repository': the name alone is not enough"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$service = $repository->loadAlmanacService();\nif ($service === null) {\n  // refuse to start cluster sync; surface a configuration error to the operator\n}","typeGuard":"function hasLoadableClusterService(PhabricatorRepository $repo) {\n  return $repo->loadAlmanacService() !== null;\n}","tryCatchPattern":"try {\n  $engine->synchronizeWorkingCopyAfterCreation();\n} catch (Exception $ex) {\n  // fail the creation job visibly; do not mark the repository healthy while the service is unresolvable\n}","preventionTips":["Always un-cluster repositories before deleting an Almanac service","Automate a config lint that every clustered repository's servicePHID resolves to a repository-type service"],"tags":["phabricator","cluster","almanac","repository-lifecycle"],"backgroundTag":"cluster-service-unavailable","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}