mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +01:00
Fix misleading error message when only cluster database masters are configured
Summary: Fixes T11446. We can raise the misleading error: > No valid databases are configured! ...when a valid master is configured but unreachable. Instead, more carefully raise either "nothing is configured" or "nothing is reachable". Test Plan: Configured only a master, artificially severed it, got "nothing is reachable" instead of "nothing is configured". Reviewers: chad Reviewed By: chad Maniphest Tasks: T11446 Differential Revision: https://secure.phabricator.com/D16386
This commit is contained in:
parent
e8083ad63a
commit
3b45608c78
1 changed files with 17 additions and 8 deletions
|
@ -122,16 +122,17 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
$replica = PhabricatorDatabaseRef::getReplicaDatabaseRef();
|
$replica = PhabricatorDatabaseRef::getReplicaDatabaseRef();
|
||||||
if (!$replica) {
|
if ($replica) {
|
||||||
throw new Exception(
|
|
||||||
pht('No valid databases are configured!'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$connection = $replica->newApplicationConnection($database);
|
$connection = $replica->newApplicationConnection($database);
|
||||||
$connection->setReadOnly(true);
|
$connection->setReadOnly(true);
|
||||||
if ($replica->isReachable($connection)) {
|
if ($replica->isReachable($connection)) {
|
||||||
return $connection;
|
return $connection;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$master && !$replica) {
|
||||||
|
$this->raiseUnconfigured($database);
|
||||||
|
}
|
||||||
|
|
||||||
$this->raiseUnreachable($database);
|
$this->raiseUnreachable($database);
|
||||||
}
|
}
|
||||||
|
@ -153,10 +154,18 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
|
||||||
$database));
|
$database));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function raiseUnconfigured($database) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Unable to establish a connection to any database host '.
|
||||||
|
'(while trying "%s"). No masters or replicas are configured.',
|
||||||
|
$database));
|
||||||
|
}
|
||||||
|
|
||||||
private function raiseUnreachable($database) {
|
private function raiseUnreachable($database) {
|
||||||
throw new PhabricatorClusterStrandedException(
|
throw new PhabricatorClusterStrandedException(
|
||||||
pht(
|
pht(
|
||||||
'Unable to establish a connection to ANY database host '.
|
'Unable to establish a connection to any database host '.
|
||||||
'(while trying "%s"). All masters and replicas are completely '.
|
'(while trying "%s"). All masters and replicas are completely '.
|
||||||
'unreachable.',
|
'unreachable.',
|
||||||
$database));
|
$database));
|
||||||
|
|
Loading…
Reference in a new issue