22use Psr\Log\LoggerInterface;
41private $trxReplicaLagStatus =
null;
66return 0;
// this is the primary DB 68return 0;
// static dataset 100// Avoid exceptions as this is used internally in critical sections 102 $lag = $this->
getLag( $conn );
110return [
'lag' => $lag,
'since' => microtime(
true ) ];
120// Real waits are implemented in the subclass. 145return [
'Server is configured as a read-only replica database.',
'role' ];
147return [
'Server is configured as a read-only static clone database.',
'role' ];
154// With REPEATABLE-READ isolation, the first SELECT establishes the read snapshot, 155// so get the replication lag estimate before any transaction SELECT queries come in. 156// This way, the lag estimate reflects what will actually be read. Also, if heartbeat 157// tables are used, this avoids counting snapshot lag as part of replication lag. 158 $this->trxReplicaLagStatus =
null;
// clear cached value first 178return $conn->
trxLevel() ? $this->trxReplicaLagStatus :
null;
Abstract class for any ephemeral data store.
Database error base class.
getSessionLagStatus(IDatabase $conn)
primaryPosWait(IDatabase $conn, DBPrimaryPos $pos, $timeout)
getPrimaryPos(IDatabase $conn)
getTopologyBasedReadOnlyReason()
getLogContext(IDatabase $conn, array $extras=[])
Create a log context to pass to PSR-3 logger functions.
__construct( $topologyRole, $logger, $srvCache)
resetReplicationLagStatus(IDatabase $conn)
doGetLag(IDatabase $conn)
Get the amount of replication lag for this database server.
getReplicaPos(IDatabase $conn)
getApproximateLagStatus(IDatabase $conn)
Get a replica DB lag estimate for this server at the start of a transaction.
string $topologyRole
Replication topology role of the server; one of the class ROLE_* constants.
getRecordedTransactionLagStatus(IDatabase $conn)
Get the replica DB lag when the current transaction started.
An object representing a primary or replica DB position in a replicated setup.
Interface to a relational database.
const ROLE_STREAMING_MASTER
Primary server than can stream writes to replica servers.
const ROLE_STATIC_CLONE
Replica server within a static dataset.
const ROLE_STREAMING_REPLICA
Replica server that receives writes from a primary server.
trxLevel()
Gets the current transaction level.
getDBname()
Get the current database name; null if there isn't one.
getServerName()
Get the readable name for the server.