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 ()
 
 getGTIDs ()
 
 getLogFile ()
 
 getLogPosition ()
 
 hasReached (DBPrimaryPos $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.
 

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 Wikimedia\Rdbms\MySQLPrimaryPos\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 328 of file MySQLPrimaryPos.php.

◆ asOfTime()

Wikimedia\Rdbms\MySQLPrimaryPos::asOfTime ( )
Since
1.25
Returns
float UNIX timestamp

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 101 of file MySQLPrimaryPos.php.

Referenced by Wikimedia\Rdbms\MySQLPrimaryPos\init().

◆ getActiveGtidCoordinates()

Wikimedia\Rdbms\MySQLPrimaryPos::getActiveGtidCoordinates ( )
protected

◆ 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 293 of file MySQLPrimaryPos.php.

Referenced by Wikimedia\Rdbms\MySQLPrimaryPos\hasReached().

◆ getGTIDs()

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

Definition at line 160 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 151 of file MySQLPrimaryPos.php.

◆ 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 143 of file MySQLPrimaryPos.php.

◆ getRelevantActiveGTIDs()

static 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 222 of file MySQLPrimaryPos.php.

References Wikimedia\Rdbms\MySQLPrimaryPos\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 105 of file MySQLPrimaryPos.php.

References Wikimedia\Rdbms\MySQLPrimaryPos\getActiveGtidCoordinates(), and Wikimedia\Rdbms\MySQLPrimaryPos\getBinlogCoordinates().

◆ init()

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

Definition at line 60 of file MySQLPrimaryPos.php.

References Wikimedia\Rdbms\MySQLPrimaryPos\asOfTime(), and Wikimedia\Rdbms\MySQLPrimaryPos\parseGTID().

Referenced by Wikimedia\Rdbms\MySQLPrimaryPos\__construct().

◆ newFromArray()

static 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 299 of file MySQLPrimaryPos.php.

◆ parseGTID()

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

Definition at line 266 of file MySQLPrimaryPos.php.

Referenced by Wikimedia\Rdbms\MySQLPrimaryPos\getActiveGtidCoordinates(), and Wikimedia\Rdbms\MySQLPrimaryPos\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 176 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 193 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 210 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 314 of file MySQLPrimaryPos.php.

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: