MediaWiki master
Wikimedia\Rdbms\MySQLPrimaryPos Class Reference

DBPrimaryPos implementation for MySQL and MariaDB. More...

Inherits Stringable, and Wikimedia\Rdbms\DBPrimaryPos.

Collaboration diagram for Wikimedia\Rdbms\MySQLPrimaryPos:

Public Member Functions

 __construct ( $position, $asOfTime)
 __toString ()
 asOfTime ()
 
Since
1.25
Returns
float UNIX timestamp

 getGTIDs ()
 getLogFile ()
 getLogPosition ()
 hasReached (DBPrimaryPos $pos)
 
Since
1.27
Parameters
DBPrimaryPos$pos
Returns
bool Whether this position is at or higher than $pos

 setActiveDomain ( $id)
 Set the GTID domain known to be used in new commits on a replication stream of interest.
 setActiveOriginServerId ( $id)
 Set the server ID known to be used in new commits on a replication stream of interest.
 setActiveOriginServerUUID ( $id)
 Set the server UUID known to be used in new commits on a replication stream of interest.
 toArray ()
 Serialization for storage.

Static Public Member Functions

static getRelevantActiveGTIDs (MySQLPrimaryPos $pos, MySQLPrimaryPos $refPos)
static newFromArray (array $data)
 Deserialization from storage.
Since
1.39
Parameters
array$dataRepresentation as returned from ::toArray()
Returns
DBPrimaryPos

Public Attributes

const CORD_EVENT = 1
 Key name of the 64 bit binary log event number of a position tuple.
const CORD_INDEX = 0
 Key name of the 6 digit binary log index number of a position tuple.

Protected Member Functions

 getActiveGtidCoordinates ()
 getBinlogCoordinates ()
 init ( $position, $asOfTime)

Static Protected Member Functions

static parseGTID ( $id)

Detailed Description

DBPrimaryPos implementation for MySQL and MariaDB.

Note that primary positions and sync logic here make some assumptions:

  • Binlog-based usage assumes single-source replication and non-hierarchical replication.
  • GTID-based usage allows getting/syncing with multi-source replication. It is assumed that GTID sets are complete (e.g. include all domains on the server).
See also
https://mariadb.com/kb/en/library/gtid/
https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-concepts.html
Access: internal

Definition at line 21 of file MySQLPrimaryPos.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\MySQLPrimaryPos::__construct ( $position,
$asOfTime )
Parameters
string$positionOne of (comma separated GTID list, <binlog file>/<64 bit integer>)
float$asOfTimeUNIX timestamp

Definition at line 52 of file MySQLPrimaryPos.php.

References init().

Member Function Documentation

◆ __toString()

Wikimedia\Rdbms\MySQLPrimaryPos::__toString ( )
Returns
string GTID set or <binary log file>/<position> (e.g db1034-bin.000976/843431247)

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 327 of file MySQLPrimaryPos.php.

References getLogFile().

Referenced by toArray().

◆ asOfTime()

Wikimedia\Rdbms\MySQLPrimaryPos::asOfTime ( )

Since
1.25
Returns
float UNIX timestamp

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 96 of file MySQLPrimaryPos.php.

Referenced by init(), and toArray().

◆ getActiveGtidCoordinates()

Wikimedia\Rdbms\MySQLPrimaryPos::getActiveGtidCoordinates ( )
protected
See also
https://mariadb.com/kb/en/mariadb/gtid
https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-concepts.html
Returns
array<string,int> Map of (server_uuid/gtid_domain_id => integer position)

Definition at line 231 of file MySQLPrimaryPos.php.

References parseGTID().

Referenced by getRelevantActiveGTIDs(), and hasReached().

◆ getBinlogCoordinates()

Wikimedia\Rdbms\MySQLPrimaryPos::getBinlogCoordinates ( )
protected
See also
https://dev.mysql.com/doc/refman/5.7/en/show-master-status.html
https://dev.mysql.com/doc/refman/5.7/en/show-slave-status.html
Returns
array|false Map of (binlog:<string>, pos:(<integer>, <integer>)) or false

Definition at line 291 of file MySQLPrimaryPos.php.

Referenced by hasReached().

◆ getGTIDs()

Wikimedia\Rdbms\MySQLPrimaryPos::getGTIDs ( )
Returns
array<string,string> Map of (server_uuid/gtid_domain_id => GTID)
Since
1.31

Definition at line 156 of file MySQLPrimaryPos.php.

◆ getLogFile()

Wikimedia\Rdbms\MySQLPrimaryPos::getLogFile ( )
Returns
string|null Name of the binary log file for this position
Since
1.31

Definition at line 147 of file MySQLPrimaryPos.php.

Referenced by __toString().

◆ getLogPosition()

Wikimedia\Rdbms\MySQLPrimaryPos::getLogPosition ( )
Returns
array<int,int|string>|null Tuple of (binary log file number, 64 bit event number)
Since
1.31

Definition at line 139 of file MySQLPrimaryPos.php.

◆ getRelevantActiveGTIDs()

Wikimedia\Rdbms\MySQLPrimaryPos::getRelevantActiveGTIDs ( MySQLPrimaryPos $pos,
MySQLPrimaryPos $refPos )
static
Parameters
MySQLPrimaryPos$pos
MySQLPrimaryPos$refPos
Returns
string[] List of active GTIDs from $pos that have domains in $refPos
Since
1.34

Definition at line 218 of file MySQLPrimaryPos.php.

References getActiveGtidCoordinates().

◆ hasReached()

Wikimedia\Rdbms\MySQLPrimaryPos::hasReached ( DBPrimaryPos $pos)

Since
1.27
Parameters
DBPrimaryPos$pos
Returns
bool Whether this position is at or higher than $pos

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 101 of file MySQLPrimaryPos.php.

References getActiveGtidCoordinates(), and getBinlogCoordinates().

◆ init()

Wikimedia\Rdbms\MySQLPrimaryPos::init ( $position,
$asOfTime )
protected
Parameters
string$position
float$asOfTime

Definition at line 60 of file MySQLPrimaryPos.php.

References asOfTime(), and parseGTID().

Referenced by __construct().

◆ newFromArray()

Wikimedia\Rdbms\MySQLPrimaryPos::newFromArray ( array $data)
static

Deserialization from storage.

Since
1.39
Parameters
array$dataRepresentation as returned from ::toArray()
Returns
DBPrimaryPos

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 298 of file MySQLPrimaryPos.php.

◆ parseGTID()

Wikimedia\Rdbms\MySQLPrimaryPos::parseGTID ( $id)
staticprotected
Parameters
string$idGTID
Returns
string[]|null (domain ID, event number, source server ID, style) for MariaDB, (source server UUID, event number, source server UUID, style) for MySQL, or null

Definition at line 262 of file MySQLPrimaryPos.php.

Referenced by getActiveGtidCoordinates(), and init().

◆ setActiveDomain()

Wikimedia\Rdbms\MySQLPrimaryPos::setActiveDomain ( $id)

Set the GTID domain known to be used in new commits on a replication stream of interest.

This makes getRelevantActiveGTIDs() filter out GTIDs from other domains

See also
MySQLPrimaryPos::getRelevantActiveGTIDs()
https://mariadb.com/kb/en/library/gtid/#gtid_domain_id
Parameters
string | int | null$id@gtid_domain_id of the active replication stream
Returns
MySQLPrimaryPos This instance (since 1.34)
Since
1.31

Definition at line 172 of file MySQLPrimaryPos.php.

◆ setActiveOriginServerId()

Wikimedia\Rdbms\MySQLPrimaryPos::setActiveOriginServerId ( $id)

Set the server ID known to be used in new commits on a replication stream of interest.

This makes getRelevantActiveGTIDs() filter out GTIDs from other origin servers

See also
MySQLPrimaryPos::getRelevantActiveGTIDs()
Parameters
string | int | null$id@server_id of the server were writes originate
Returns
MySQLPrimaryPos This instance (since 1.34)
Since
1.31

Definition at line 189 of file MySQLPrimaryPos.php.

◆ setActiveOriginServerUUID()

Wikimedia\Rdbms\MySQLPrimaryPos::setActiveOriginServerUUID ( $id)

Set the server UUID known to be used in new commits on a replication stream of interest.

This makes getRelevantActiveGTIDs() filter out GTIDs from other origin servers

See also
MySQLPrimaryPos::getRelevantActiveGTIDs()
Parameters
string | null$id@server_uuid of the server were writes originate
Returns
MySQLPrimaryPos This instance (since 1.34)
Since
1.31

Definition at line 206 of file MySQLPrimaryPos.php.

◆ toArray()

Wikimedia\Rdbms\MySQLPrimaryPos::toArray ( )

Serialization for storage.

Since
1.39
Returns
array Representation for use by ::newFromArray()

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 313 of file MySQLPrimaryPos.php.

References __toString(), asOfTime(), and return.

Member Data Documentation

◆ CORD_EVENT

const Wikimedia\Rdbms\MySQLPrimaryPos::CORD_EVENT = 1

Key name of the 64 bit binary log event number of a position tuple.

Definition at line 46 of file MySQLPrimaryPos.php.

◆ CORD_INDEX

const Wikimedia\Rdbms\MySQLPrimaryPos::CORD_INDEX = 0

Key name of the 6 digit binary log index number of a position tuple.

Definition at line 44 of file MySQLPrimaryPos.php.


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