MediaWiki REL1_39
Wikimedia\Rdbms\MySQLPrimaryPos Class Reference

DBPrimaryPos implementation for MySQL and MariaDB. More...

Inheritance diagram for Wikimedia\Rdbms\MySQLPrimaryPos:
Collaboration diagram for Wikimedia\Rdbms\MySQLPrimaryPos:

Public Member Functions

 __construct ( $position, $asOfTime)
 
 __serialize ()
 
 __toString ()
 
 __unserialize ( $data)
 
 asOfTime ()
 
 channelsMatch (DBPrimaryPos $pos)
 
 getGTIDs ()
 
 getLogFile ()
 
 getLogPosition ()
 
 hasReached (DBPrimaryPos $pos)
 
 serialize ()
 
 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.
 
 unserialize ( $serialized)
 

Static Public Member Functions

static getRelevantActiveGTIDs (MySQLPrimaryPos $pos, MySQLPrimaryPos $refPos)
 
static newFromArray (array $data)
 Deserialization from storage.
 

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

◆ __serialize()

Wikimedia\Rdbms\MySQLPrimaryPos::__serialize ( )

Definition at line 326 of file MySQLPrimaryPos.php.

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

◆ __unserialize()

Wikimedia\Rdbms\MySQLPrimaryPos::__unserialize ( $data)

Definition at line 340 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().

◆ channelsMatch()

Wikimedia\Rdbms\MySQLPrimaryPos::channelsMatch ( DBPrimaryPos $pos)
Since
1.27
Parameters
DBPrimaryPos$pos
Returns
bool Whether this position appears to be for the same channel as another

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 139 of file MySQLPrimaryPos.php.

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

◆ getActiveGtidCoordinates()

Wikimedia\Rdbms\MySQLPrimaryPos::getActiveGtidCoordinates ( )
protected

◆ getBinlogCoordinates()

Wikimedia\Rdbms\MySQLPrimaryPos::getBinlogCoordinates ( )
protected

◆ getGTIDs()

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

Definition at line 183 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 174 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 166 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 245 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 357 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 289 of file MySQLPrimaryPos.php.

Referenced by Wikimedia\Rdbms\MySQLPrimaryPos\getActiveGtidCoordinates(), and Wikimedia\Rdbms\MySQLPrimaryPos\init().

◆ serialize()

Wikimedia\Rdbms\MySQLPrimaryPos::serialize ( )

Definition at line 322 of file MySQLPrimaryPos.php.

◆ 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 199 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 216 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 233 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 363 of file MySQLPrimaryPos.php.

◆ unserialize()

Wikimedia\Rdbms\MySQLPrimaryPos::unserialize ( $serialized)

Definition at line 336 of file MySQLPrimaryPos.php.


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