MediaWiki master
Wikimedia\Rdbms\Replication\MysqlReplicationReporter Class Reference

Inherits Wikimedia\Rdbms\Replication\ReplicationReporter.

Collaboration diagram for Wikimedia\Rdbms\Replication\MysqlReplicationReporter:

Public Member Functions

 __construct ( $topologyRole, $logger, $srvCache, $lagDetectionMethod, $lagDetectionOptions, $useGTIDs)
 
 getApproximateLagStatus (IDatabase $conn)
 Get a replica DB lag estimate for this server at the start of a transaction.
 
 getPrimaryPos (IDatabase $conn)
 Get the position of the primary DB from SHOW MASTER STATUS.
 
 getReplicaPos (IDatabase $conn)
 Get the position of the primary DB from SHOW SLAVE STATUS.
 
 getReplicationSafetyInfo (IDatabase $conn, $fname)
 
 primaryPosWait (IDatabase $conn, DBPrimaryPos $pos, $timeout)
 
- Public Member Functions inherited from Wikimedia\Rdbms\Replication\ReplicationReporter
 __construct ( $topologyRole, $logger, $srvCache)
 
 getLag (IDatabase $conn)
 
 getSessionLagStatus (IDatabase $conn)
 
 getTopologyBasedReadOnlyReason ()
 
 getTopologyRole ()
 
 resetReplicationLagStatus (IDatabase $conn)
 

Protected Member Functions

 doGetLag (IDatabase $conn)
 Get the amount of replication lag for this database server.
 
 fetchSecondsSinceHeartbeat (IDatabase $conn)
 
 getLagFromPtHeartbeat (IDatabase $conn)
 
 getLagFromSlaveStatus (IDatabase $conn)
 
 getServerGTIDs (IDatabase $conn, $fname)
 
 getServerId (IDatabase $conn)
 
 getServerRoleStatus (IDatabase $conn, $role, $fname)
 
 getServerUUID (IDatabase $conn)
 
 useGTIDs ()
 
- Protected Member Functions inherited from Wikimedia\Rdbms\Replication\ReplicationReporter
 getLogContext (IDatabase $conn, array $extras=[])
 Create a log context to pass to PSR-3 logger functions.
 
 getRecordedTransactionLagStatus (IDatabase $conn)
 Get the replica DB lag when the current transaction started.
 

Protected Attributes

string $lagDetectionMethod
 Method to detect replica DB lag.
 
array $lagDetectionOptions = []
 Method to detect replica DB lag.
 
MySQLPrimaryPos $lastKnownReplicaPos
 
bool $useGTIDs = false
 bool Whether to use GTID methods
 
- Protected Attributes inherited from Wikimedia\Rdbms\Replication\ReplicationReporter
LoggerInterface $logger
 
BagOStuff $srvCache
 
string $topologyRole
 Replication topology role of the server; one of the class ROLE_* constants.
 

Detailed Description

Access: internal
Since
1.40

Definition at line 37 of file MysqlReplicationReporter.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ doGetLag()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::doGetLag ( IDatabase $conn)
protected

Get the amount of replication lag for this database server.

Callers should avoid using this method while a transaction is active

See also
getLag()
Parameters
IDatabase$connTo make queries
Returns
float|int|false Database replication lag in seconds or false on error
Exceptions
DBError

Reimplemented from Wikimedia\Rdbms\Replication\ReplicationReporter.

Definition at line 68 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getLagFromPtHeartbeat(), and Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getLagFromSlaveStatus().

◆ fetchSecondsSinceHeartbeat()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::fetchSecondsSinceHeartbeat ( IDatabase $conn)
protected
Parameters
IDatabase$connTo make queries
Returns
float|null Elapsed seconds since the newest beat or null if none was found
See also
https://www.percona.com/doc/percona-toolkit/2.1/pt-heartbeat.html

Definition at line 146 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\Platform\ISQLPlatform\makeList(), and Wikimedia\Rdbms\IDatabase\query().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getLagFromPtHeartbeat().

◆ getApproximateLagStatus()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getApproximateLagStatus ( IDatabase $conn)

Get a replica DB lag estimate for this server at the start of a transaction.

This is a no-op unless the server is known a priori to be a replica DB

Parameters
IDatabase$connTo make queries
Returns
array ('lag': seconds or false on error, 'since': UNIX timestamp of estimate)
Since
1.27 in Database, moved to ReplicationReporter in 1.40

Reimplemented from Wikimedia\Rdbms\Replication\ReplicationReporter.

Definition at line 172 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\IReadableDatabase\getServerName().

◆ getLagFromPtHeartbeat()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getLagFromPtHeartbeat ( IDatabase $conn)
protected

◆ getLagFromSlaveStatus()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getLagFromSlaveStatus ( IDatabase $conn)
protected
Parameters
IDatabase$connTo make queries
Returns
int|false Second of lag

Definition at line 80 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\IDatabase\query().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\doGetLag().

◆ getPrimaryPos()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getPrimaryPos ( IDatabase $conn)

◆ getReplicaPos()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getReplicaPos ( IDatabase $conn)

◆ getReplicationSafetyInfo()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getReplicationSafetyInfo ( IDatabase $conn,
$fname )
Parameters
IDatabase$connTo make queries
string$fname
Returns
stdClass Process cached row

Definition at line 195 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\IReadableDatabase\selectRow().

◆ getServerGTIDs()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getServerGTIDs ( IDatabase $conn,
$fname )
protected
Parameters
IDatabase$connTo make queries
string$fname
Returns
string[]

Definition at line 473 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\IDatabase\query().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getPrimaryPos(), and Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getReplicaPos().

◆ getServerId()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getServerId ( IDatabase $conn)
protected
Parameters
IDatabase$connTo make queries
Returns
string Value of server_id (32-bit integer, unique to the replication topology)
Exceptions
DBQueryError

Definition at line 422 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\IReadableDatabase\getServerName(), and Wikimedia\Rdbms\IDatabase\query().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getPrimaryPos().

◆ getServerRoleStatus()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getServerRoleStatus ( IDatabase $conn,
$role,
$fname )
protected
Parameters
IDatabase$connTo make queries
string$roleOne of "MASTER"/"SLAVE"
string$fname
Returns
array<string,mixed>|null Latest available server status row; false on failure

Definition at line 512 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\IDatabase\query().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getPrimaryPos(), and Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getReplicaPos().

◆ getServerUUID()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::getServerUUID ( IDatabase $conn)
protected
Parameters
IDatabase$connTo make queries
Returns
string|null Value of server_uuid (hyphenated 128-bit hex string, globally unique)
Exceptions
DBQueryError

Definition at line 447 of file MysqlReplicationReporter.php.

References Wikimedia\Rdbms\IReadableDatabase\getServerName(), and Wikimedia\Rdbms\IDatabase\query().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getPrimaryPos().

◆ primaryPosWait()

◆ useGTIDs()

Wikimedia\Rdbms\Replication\MysqlReplicationReporter::useGTIDs ( )
protected

Member Data Documentation

◆ $lagDetectionMethod

string Wikimedia\Rdbms\Replication\MysqlReplicationReporter::$lagDetectionMethod
protected

Method to detect replica DB lag.

Definition at line 41 of file MysqlReplicationReporter.php.

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\__construct().

◆ $lagDetectionOptions

array Wikimedia\Rdbms\Replication\MysqlReplicationReporter::$lagDetectionOptions = []
protected

Method to detect replica DB lag.

Definition at line 43 of file MysqlReplicationReporter.php.

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\__construct().

◆ $lastKnownReplicaPos

MySQLPrimaryPos Wikimedia\Rdbms\Replication\MysqlReplicationReporter::$lastKnownReplicaPos
protected

Definition at line 39 of file MysqlReplicationReporter.php.

◆ $useGTIDs

bool Wikimedia\Rdbms\Replication\MysqlReplicationReporter::$useGTIDs = false
protected

The documentation for this class was generated from the following file: