diff --git a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php --- a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php +++ b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php @@ -559,8 +559,7 @@ return false; } - // TODO: For now, this is only supported for Git. - if (!$repository->isGit()) { + if (!$repository->supportsSynchronization()) { return false; } diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -1929,10 +1929,31 @@ 'Cluster hosts must correctly route their intracluster requests.')); } + if (count($results) > 1) { + if (!$this->supportsSynchronization()) { + throw new Exception( + pht( + 'Repository "%s" is bound to multiple active repository hosts, '. + 'but this repository does not support cluster synchronization. '. + 'Declusterize this repository or move it to a service with only '. + 'one host.', + $this->getDisplayName())); + } + } + shuffle($results); return head($results); } + public function supportsSynchronization() { + // TODO: For now, this is only supported for Git. + if (!$this->isGit()) { + return false; + } + + return true; + } + public function getAlmanacServiceCacheKey() { $service_phid = $this->getAlmanacServicePHID(); if (!$service_phid) {