Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if ($master && !$master->isSevered()) { | ||||
} | } | ||||
PhabricatorEnv::setReadOnly( | PhabricatorEnv::setReadOnly( | ||||
true, | true, | ||||
PhabricatorEnv::READONLY_UNREACHABLE); | PhabricatorEnv::READONLY_UNREACHABLE); | ||||
} | } | ||||
} | } | ||||
$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); | ||||
} | } | ||||
private function raiseImproperWrite($database) { | private function raiseImproperWrite($database) { | ||||
throw new PhabricatorClusterImproperWriteException( | throw new PhabricatorClusterImproperWriteException( | ||||
pht( | pht( | ||||
'Unable to establish a write-mode connection (to application '. | 'Unable to establish a write-mode connection (to application '. | ||||
'database "%s") because Phabricator is in read-only mode. Whatever '. | 'database "%s") because Phabricator is in read-only mode. Whatever '. | ||||
'you are trying to do does not function correctly in read-only mode.', | 'you are trying to do does not function correctly in read-only mode.', | ||||
$database)); | $database)); | ||||
} | } | ||||
private function raiseImpossibleWrite($database) { | private function raiseImpossibleWrite($database) { | ||||
throw new PhabricatorClusterImpossibleWriteException( | throw new PhabricatorClusterImpossibleWriteException( | ||||
pht( | pht( | ||||
'Unable to connect to master database ("%s"). This is a severe '. | 'Unable to connect to master database ("%s"). This is a severe '. | ||||
'failure; your request did not complete.', | 'failure; your request did not complete.', | ||||
$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)); | ||||
} | } | ||||
/** | /** | ||||
* @task config | * @task config | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |