@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

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

+20 -9
+20 -9
src/infrastructure/cluster/PhabricatorDatabaseRef.php
··· 12 12 const REPLICATION_MASTER_REPLICA = 'master-replica'; 13 13 const REPLICATION_REPLICA_NONE = 'replica-none'; 14 14 const REPLICATION_SLOW = 'replica-slow'; 15 + const REPLICATION_NOT_REPLICATING = 'not-replicating'; 15 16 16 17 const KEY_REFS = 'cluster.db.refs'; 17 18 const KEY_INDIVIDUAL = 'cluster.db.individual'; ··· 196 197 self::REPLICATION_REPLICA_NONE => array( 197 198 'icon' => 'fa-download', 198 199 'color' => 'red', 199 - 'label' => pht('Not Replicating'), 200 + 'label' => pht('Not A Replica'), 200 201 ), 201 202 self::REPLICATION_SLOW => array( 202 203 'icon' => 'fa-hourglass', 203 204 'color' => 'red', 204 205 'label' => pht('Slow Replication'), 206 + ), 207 + self::REPLICATION_NOT_REPLICATING => array( 208 + 'icon' => 'fa-exclamation-triangle', 209 + 'color' => 'red', 210 + 'label' => pht('Not Replicating'), 205 211 ), 206 212 ); 207 213 } ··· 330 336 } 331 337 332 338 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 + } 341 352 } 342 353 } 343 354 }