Skip to content

Commit 01040e4

Browse files
author
epriestley
committedJul 4, 2016
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
1 parent fa6d3e2 commit 01040e4

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed
 

‎src/infrastructure/cluster/PhabricatorDatabaseRef.php

+20-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ final class PhabricatorDatabaseRef
1212
const REPLICATION_MASTER_REPLICA = 'master-replica';
1313
const REPLICATION_REPLICA_NONE = 'replica-none';
1414
const REPLICATION_SLOW = 'replica-slow';
15+
const REPLICATION_NOT_REPLICATING = 'not-replicating';
1516

1617
const KEY_REFS = 'cluster.db.refs';
1718
const KEY_INDIVIDUAL = 'cluster.db.individual';
@@ -196,13 +197,18 @@ public static function getReplicaStatusMap() {
196197
self::REPLICATION_REPLICA_NONE => array(
197198
'icon' => 'fa-download',
198199
'color' => 'red',
199-
'label' => pht('Not Replicating'),
200+
'label' => pht('Not A Replica'),
200201
),
201202
self::REPLICATION_SLOW => array(
202203
'icon' => 'fa-hourglass',
203204
'color' => 'red',
204205
'label' => pht('Slow Replication'),
205206
),
207+
self::REPLICATION_NOT_REPLICATING => array(
208+
'icon' => 'fa-exclamation-triangle',
209+
'color' => 'red',
210+
'label' => pht('Not Replicating'),
211+
),
206212
);
207213
}
208214

@@ -330,14 +336,19 @@ public static function queryAll() {
330336
}
331337

332338
if ($is_replica) {
333-
$latency = (int)idx($replica_status, 'Seconds_Behind_Master');
334-
$ref->setReplicaDelay($latency);
335-
if ($latency > 30) {
336-
$ref->setReplicaStatus(self::REPLICATION_SLOW);
337-
$ref->setReplicaMessage(
338-
pht(
339-
'This replica is lagging far behind the master. Data is at '.
340-
'risk!'));
339+
$latency = idx($replica_status, 'Seconds_Behind_Master');
340+
if (!strlen($latency)) {
341+
$ref->setReplicaStatus(self::REPLICATION_NOT_REPLICATING);
342+
} else {
343+
$latency = (int)$latency;
344+
$ref->setReplicaDelay($latency);
345+
if ($latency > 30) {
346+
$ref->setReplicaStatus(self::REPLICATION_SLOW);
347+
$ref->setReplicaMessage(
348+
pht(
349+
'This replica is lagging far behind the master. Data is at '.
350+
'risk!'));
351+
}
341352
}
342353
}
343354
}

0 commit comments

Comments
 (0)
Failed to load comments.