Page MenuHomePhabricator

D16904.id40702.diff
No OneTemporary

D16904.id40702.diff

diff --git a/src/applications/config/check/PhabricatorDatabaseSetupCheck.php b/src/applications/config/check/PhabricatorDatabaseSetupCheck.php
--- a/src/applications/config/check/PhabricatorDatabaseSetupCheck.php
+++ b/src/applications/config/check/PhabricatorDatabaseSetupCheck.php
@@ -43,7 +43,7 @@
$port));
}
- $refs = PhabricatorDatabaseRef::getActiveDatabaseRefs();
+ $refs = PhabricatorDatabaseRef::queryAll();
$refs = mpull($refs, null, 'getRefKey');
// Test if we can connect to each database first. If we can not connect
@@ -164,5 +164,47 @@
return true;
}
+
+ // NOTE: It's possible that replication is broken but we have not been
+ // granted permission to "SHOW SLAVE STATUS" so we can't figure it out.
+ // We allow this kind of configuration and survive these checks, trusting
+ // that operations knows what they're doing. This issue is shown on the
+ // "Database Servers" console.
+
+ switch ($ref->getReplicaStatus()) {
+ case PhabricatorDatabaseRef::REPLICATION_MASTER_REPLICA:
+ $message = pht(
+ 'Database host "%s" is configured as a master, but is replicating '.
+ 'another host. This is dangerous and can mangle or destroy data. '.
+ 'Only replicas should be replicating. Stop replication on the '.
+ 'host or reconfigure Phabricator.',
+ $ref->getRefKey());
+
+ $this->newIssue('db.master.replicating')
+ ->setName(pht('Replicating Master'))
+ ->setIsFatal(true)
+ ->setMessage($message);
+
+ return true;
+ case PhabricatorDatabaseRef::REPLICATION_REPLICA_NONE:
+ case PhabricatorDatabaseRef::REPLICATION_NOT_REPLICATING:
+ if (!$ref->getIsMaster()) {
+ $message = pht(
+ 'Database replica "%s" is listed as a replica, but is not '.
+ 'currently replicating. You are vulnerable to data loss if '.
+ 'the master fails.',
+ $ref->getRefKey());
+
+ // This isn't a fatal because it can normally only put data at risk,
+ // not actually do anything destructive or unrecoverable.
+
+ $this->newIssue('db.replica.not-replicating')
+ ->setName(pht('Nonreplicating Replica'))
+ ->setMessage($message);
+ }
+ break;
+ }
+
+
}
}
diff --git a/src/infrastructure/cluster/PhabricatorDatabaseRef.php b/src/infrastructure/cluster/PhabricatorDatabaseRef.php
--- a/src/infrastructure/cluster/PhabricatorDatabaseRef.php
+++ b/src/infrastructure/cluster/PhabricatorDatabaseRef.php
@@ -308,13 +308,12 @@
}
public static function queryAll() {
- $refs = self::newRefs();
+ $refs = self::getActiveDatabaseRefs();
+ return self::queryRefs($refs);
+ }
+ private static function queryRefs(array $refs) {
foreach ($refs as $ref) {
- if ($ref->getDisabled()) {
- continue;
- }
-
$conn = $ref->newManagementConnection();
$t_start = microtime(true);
diff --git a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
--- a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
+++ b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
@@ -842,6 +842,8 @@
$no_quickstart,
$init_only) {
+ $patches = $this->patches;
+
$applied = $api->getAppliedPatches();
if ($applied === null) {
if ($this->dryRun) {
@@ -864,7 +866,7 @@
// adjustment phase.
$this->didInitialize = true;
- $legacy = $api->getLegacyPatches($this->patches);
+ $legacy = $api->getLegacyPatches($patches);
if ($legacy || $no_quickstart || $init_only) {
// If we have legacy patches, we can't quickstart.
@@ -921,14 +923,14 @@
while (true) {
$applied_something = false;
- foreach ($this->patches as $key => $patch) {
+ foreach ($patches as $key => $patch) {
if (isset($applied[$key])) {
- unset($this->patches[$key]);
+ unset($patches[$key]);
continue;
}
if ($apply_only && $apply_only != $key) {
- unset($this->patches[$key]);
+ unset($patches[$key]);
continue;
}
@@ -968,17 +970,17 @@
}
}
- unset($this->patches[$key]);
+ unset($patches[$key]);
$applied[$key] = true;
}
if (!$applied_something) {
- if (count($this->patches)) {
+ if (count($patches)) {
throw new Exception(
pht(
'Some patches could not be applied to "%s": %s',
$api->getRef()->getRefKey(),
- implode(', ', array_keys($this->patches))));
+ implode(', ', array_keys($patches))));
} else if (!$this->dryRun && !$apply_only) {
echo pht(
'Storage is up to date on "%s". Use "%s" for details.',

File Metadata

Mime Type
text/plain
Expires
Oct 15 2024, 3:05 AM (5 w, 19 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6711072
Default Alt Text
D16904.id40702.diff (4 KB)

Event Timeline