@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+17 -8
+17 -8
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
··· 122 122 } 123 123 124 124 $replica = PhabricatorDatabaseRef::getReplicaDatabaseRef(); 125 - if (!$replica) { 126 - throw new Exception( 127 - pht('No valid databases are configured!')); 125 + if ($replica) { 126 + $connection = $replica->newApplicationConnection($database); 127 + $connection->setReadOnly(true); 128 + if ($replica->isReachable($connection)) { 129 + return $connection; 130 + } 128 131 } 129 132 130 - $connection = $replica->newApplicationConnection($database); 131 - $connection->setReadOnly(true); 132 - if ($replica->isReachable($connection)) { 133 - return $connection; 133 + if (!$master && !$replica) { 134 + $this->raiseUnconfigured($database); 134 135 } 135 136 136 137 $this->raiseUnreachable($database); ··· 153 154 $database)); 154 155 } 155 156 157 + private function raiseUnconfigured($database) { 158 + throw new Exception( 159 + pht( 160 + 'Unable to establish a connection to any database host '. 161 + '(while trying "%s"). No masters or replicas are configured.', 162 + $database)); 163 + } 164 + 156 165 private function raiseUnreachable($database) { 157 166 throw new PhabricatorClusterStrandedException( 158 167 pht( 159 - 'Unable to establish a connection to ANY database host '. 168 + 'Unable to establish a connection to any database host '. 160 169 '(while trying "%s"). All masters and replicas are completely '. 161 170 'unreachable.', 162 171 $database));