Page MenuHomePhabricator

Misleading "No valid databases are configured!" error can arise from newClusterConnection()
Closed, ResolvedPublic

Description

This error is reachable if no replicas are configured and we sever from the master:

private function newClusterConnection($database, $mode) {
  $master = PhabricatorDatabaseRef::getMasterDatabaseRef();

  if ($master && !$master->isSevered()) {
    $connection = $master->newApplicationConnection($database);
    if ($master->isReachable($connection)) {
      return $connection;
    } else {
      if ($mode == 'w') {
        $this->raiseImpossibleWrite($database);
      }
      PhabricatorEnv::setReadOnly(
        true,
        PhabricatorEnv::READONLY_UNREACHABLE);
    }
  }

  $replica = PhabricatorDatabaseRef::getReplicaDatabaseRef();
  if (!$replica) {
    throw new Exception(
      pht('No valid databases are configured!'));
  }

  ...

In this case, it is misleading and suggests a configuration problem when the real issue is likely operational.