mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-29 16:08:22 +01:00
Correctly disinguish between "0 seconds behind master" and "not replicating"
Summary: Fixes T11159. We get two different values here (`NULL` and `0`) with different meanings. Test Plan: - Ran `STOP SLAVE;`. - Saw this: {F1710181} - Ran `START SLAVE;`. - Back to normal. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11159 Differential Revision: https://secure.phabricator.com/D16225
This commit is contained in:
parent
fa6d3e2de3
commit
01040e4573
1 changed files with 20 additions and 9 deletions
|
@ -12,6 +12,7 @@ final class PhabricatorDatabaseRef
|
|||
const REPLICATION_MASTER_REPLICA = 'master-replica';
|
||||
const REPLICATION_REPLICA_NONE = 'replica-none';
|
||||
const REPLICATION_SLOW = 'replica-slow';
|
||||
const REPLICATION_NOT_REPLICATING = 'not-replicating';
|
||||
|
||||
const KEY_REFS = 'cluster.db.refs';
|
||||
const KEY_INDIVIDUAL = 'cluster.db.individual';
|
||||
|
@ -196,13 +197,18 @@ final class PhabricatorDatabaseRef
|
|||
self::REPLICATION_REPLICA_NONE => array(
|
||||
'icon' => 'fa-download',
|
||||
'color' => 'red',
|
||||
'label' => pht('Not Replicating'),
|
||||
'label' => pht('Not A Replica'),
|
||||
),
|
||||
self::REPLICATION_SLOW => array(
|
||||
'icon' => 'fa-hourglass',
|
||||
'color' => 'red',
|
||||
'label' => pht('Slow Replication'),
|
||||
),
|
||||
self::REPLICATION_NOT_REPLICATING => array(
|
||||
'icon' => 'fa-exclamation-triangle',
|
||||
'color' => 'red',
|
||||
'label' => pht('Not Replicating'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -330,14 +336,19 @@ final class PhabricatorDatabaseRef
|
|||
}
|
||||
|
||||
if ($is_replica) {
|
||||
$latency = (int)idx($replica_status, 'Seconds_Behind_Master');
|
||||
$ref->setReplicaDelay($latency);
|
||||
if ($latency > 30) {
|
||||
$ref->setReplicaStatus(self::REPLICATION_SLOW);
|
||||
$ref->setReplicaMessage(
|
||||
pht(
|
||||
'This replica is lagging far behind the master. Data is at '.
|
||||
'risk!'));
|
||||
$latency = idx($replica_status, 'Seconds_Behind_Master');
|
||||
if (!strlen($latency)) {
|
||||
$ref->setReplicaStatus(self::REPLICATION_NOT_REPLICATING);
|
||||
} else {
|
||||
$latency = (int)$latency;
|
||||
$ref->setReplicaDelay($latency);
|
||||
if ($latency > 30) {
|
||||
$ref->setReplicaStatus(self::REPLICATION_SLOW);
|
||||
$ref->setReplicaMessage(
|
||||
pht(
|
||||
'This replica is lagging far behind the master. Data is at '.
|
||||
'risk!'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue