MediaWiki master
Wikimedia\Rdbms\Replication\ReplicationReporter Class Reference

Inherited by Wikimedia\Rdbms\Replication\MysqlReplicationReporter.

Collaboration diagram for Wikimedia\Rdbms\Replication\ReplicationReporter:

Public Member Functions

 __construct ( $topologyRole, $logger, $srvCache)
 
 getLag (IDatabase $conn)
 
 getPrimaryPos (IDatabase $conn)
 
 getReplicaPos (IDatabase $conn)
 
 getSessionLagStatus (IDatabase $conn)
 
 getTopologyBasedReadOnlyReason ()
 
 getTopologyBasedServerId (IDatabase $conn)
 
 getTopologyRole ()
 
 primaryPosWait (IDatabase $conn, DBPrimaryPos $pos, $timeout)
 
 resetReplicationLagStatus (IDatabase $conn)
 

Protected Member Functions

 doGetLag (IDatabase $conn)
 Get the amount of replication lag for this database server.
 
 getApproximateLagStatus (IDatabase $conn)
 Get a replica DB lag estimate for this server at the start of a transaction.
 
 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

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 33 of file ReplicationReporter.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\Replication\ReplicationReporter::__construct ( $topologyRole,
$logger,
$srvCache )

Member Function Documentation

◆ doGetLag()

Wikimedia\Rdbms\Replication\ReplicationReporter::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 in Wikimedia\Rdbms\Replication\MysqlReplicationReporter.

Definition at line 74 of file ReplicationReporter.php.

Referenced by Wikimedia\Rdbms\Replication\ReplicationReporter\getLag().

◆ getApproximateLagStatus()

Wikimedia\Rdbms\Replication\ReplicationReporter::getApproximateLagStatus ( IDatabase $conn)
protected

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 in Wikimedia\Rdbms\Replication\MysqlReplicationReporter.

Definition at line 87 of file ReplicationReporter.php.

References Wikimedia\Rdbms\Replication\ReplicationReporter\getLag().

Referenced by Wikimedia\Rdbms\Replication\ReplicationReporter\getSessionLagStatus(), and Wikimedia\Rdbms\Replication\ReplicationReporter\resetReplicationLagStatus().

◆ getLag()

Wikimedia\Rdbms\Replication\ReplicationReporter::getLag ( IDatabase $conn)

◆ getLogContext()

Wikimedia\Rdbms\Replication\ReplicationReporter::getLogContext ( IDatabase $conn,
array $extras = [] )
protected

Create a log context to pass to PSR-3 logger functions.

Parameters
IDatabase$connTo make queries
array$extrasAdditional data to add to context
Returns
array

Definition at line 169 of file ReplicationReporter.php.

References Wikimedia\Rdbms\IReadableDatabase\getDBname(), and Wikimedia\Rdbms\IReadableDatabase\getServerName().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getLagFromPtHeartbeat(), and Wikimedia\Rdbms\Replication\MysqlReplicationReporter\primaryPosWait().

◆ getPrimaryPos()

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

◆ getRecordedTransactionLagStatus()

Wikimedia\Rdbms\Replication\ReplicationReporter::getRecordedTransactionLagStatus ( IDatabase $conn)
finalprotected

Get the replica DB lag when the current transaction started.

This is useful given that transactions might use point-in-time read snapshots, in which case the lag estimate should be recorded just before the transaction establishes the read snapshot (either BEGIN or the first SELECT/write query).

If snapshots are not used, it is still safe to be pessimistic.

This returns null if there is no transaction or the lag status was not yet recorded.

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

Definition at line 154 of file ReplicationReporter.php.

References Wikimedia\Rdbms\IDatabase\trxLevel().

Referenced by Wikimedia\Rdbms\Replication\MysqlReplicationReporter\getLagFromPtHeartbeat(), and Wikimedia\Rdbms\Replication\ReplicationReporter\getSessionLagStatus().

◆ getReplicaPos()

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

◆ getSessionLagStatus()

Wikimedia\Rdbms\Replication\ReplicationReporter::getSessionLagStatus ( IDatabase $conn)

◆ getTopologyBasedReadOnlyReason()

Wikimedia\Rdbms\Replication\ReplicationReporter::getTopologyBasedReadOnlyReason ( )
Returns
array|null Tuple of (reason string, "role") if read-only; null otherwise

Definition at line 120 of file ReplicationReporter.php.

◆ getTopologyBasedServerId()

Wikimedia\Rdbms\Replication\ReplicationReporter::getTopologyBasedServerId ( IDatabase $conn)
Parameters
IDatabase$connTo make queries
Returns
string|null 32 bit integer ID; null if not applicable or unknown

Reimplemented in Wikimedia\Rdbms\Replication\MysqlReplicationReporter.

Definition at line 184 of file ReplicationReporter.php.

◆ getTopologyRole()

Wikimedia\Rdbms\Replication\ReplicationReporter::getTopologyRole ( )

◆ primaryPosWait()

Wikimedia\Rdbms\Replication\ReplicationReporter::primaryPosWait ( IDatabase $conn,
DBPrimaryPos $pos,
$timeout )

◆ resetReplicationLagStatus()

Wikimedia\Rdbms\Replication\ReplicationReporter::resetReplicationLagStatus ( IDatabase $conn)

Member Data Documentation

◆ $logger

LoggerInterface Wikimedia\Rdbms\Replication\ReplicationReporter::$logger
protected

◆ $srvCache

BagOStuff Wikimedia\Rdbms\Replication\ReplicationReporter::$srvCache
protected

◆ $topologyRole

string Wikimedia\Rdbms\Replication\ReplicationReporter::$topologyRole
protected

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