MediaWiki  master
Wikimedia\Rdbms\MySQLPrimaryPos Class Reference

DBPrimaryPos class for MySQL/MariaDB. More...

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

Public Member Functions

 __construct ( $position, $asOfTime)
 
 __toString ()
 
 asOfTime ()
 
 channelsMatch (DBPrimaryPos $pos)
 
 getGTIDs ()
 
 getLogFile ()
 
 getLogName ()
 
 getLogPosition ()
 
 hasReached (DBPrimaryPos $pos)
 
 serialize ()
 
 setActiveDomain ( $id)
 Set the GTID domain known to be used in new commits on a replication stream of interest. More...
 
 setActiveOriginServerId ( $id)
 Set the server ID known to be used in new commits on a replication stream of interest. More...
 
 setActiveOriginServerUUID ( $id)
 Set the server UUID known to be used in new commits on a replication stream of interest. More...
 
 unserialize ( $serialized)
 

Static Public Member Functions

static getRelevantActiveGTIDs (MySQLPrimaryPos $pos, MySQLPrimaryPos $refPos)
 

Protected Member Functions

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

Static Protected Member Functions

static parseGTID ( $id)
 

Private Attributes

string null $activeDomain
 Active GTID domain ID. More...
 
string null $activeServerId
 ID of the server were DB writes originate. More...
 
string null $activeServerUUID
 UUID of the server were DB writes originate. More...
 
float $asOfTime = 0.0
 UNIX timestamp. More...
 
string null $binLog
 Base name of all Binary Log files. More...
 
string[] $gtids = []
 Map of (server_uuid/gtid_domain_id => GTID) More...
 
array< int, int|string > null $logPos
 Binary Log position tuple (index number, event number) More...
 
string $style
 One of (BINARY_LOG, GTID_MYSQL, GTID_MARIA) More...
 
const BINARY_LOG = 'binary-log'
 
const GTID_MARIA = 'gtid-maria'
 
const GTID_MYSQL = 'gtid-mysql'
 

Detailed Description

DBPrimaryPos class for MySQL/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
Since
1.37

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

References Wikimedia\Rdbms\MySQLPrimaryPos\$asOfTime, and 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 360 of file MySQLPrimaryPos.php.

References Wikimedia\Rdbms\MySQLPrimaryPos\getLogFile().

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

◆ asOfTime()

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

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 100 of file MySQLPrimaryPos.php.

References Wikimedia\Rdbms\MySQLPrimaryPos\$asOfTime.

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

◆ channelsMatch()

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

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 138 of file MySQLPrimaryPos.php.

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

◆ getActiveGtidCoordinates()

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

References Wikimedia\Rdbms\MySQLPrimaryPos\$gtids.

◆ getLogFile()

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

Definition at line 181 of file MySQLPrimaryPos.php.

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

◆ getLogName()

Wikimedia\Rdbms\MySQLPrimaryPos::getLogName ( )
Returns
string|null Base name of binary log files
Since
1.31

Definition at line 165 of file MySQLPrimaryPos.php.

References Wikimedia\Rdbms\MySQLPrimaryPos\$binLog.

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

References Wikimedia\Rdbms\MySQLPrimaryPos\$logPos.

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

References Wikimedia\Rdbms\MySQLPrimaryPos\getActiveGtidCoordinates().

◆ hasReached()

Wikimedia\Rdbms\MySQLPrimaryPos::hasReached ( DBPrimaryPos  $pos)
Parameters
DBPrimaryPos$pos
Returns
bool Whether this position is at or higher than $pos
Since
1.27

Implements Wikimedia\Rdbms\DBPrimaryPos.

Definition at line 104 of file MySQLPrimaryPos.php.

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

◆ init()

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

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

◆ serialize()

Wikimedia\Rdbms\MySQLPrimaryPos::serialize ( )

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

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

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

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

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

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

◆ unserialize()

Member Data Documentation

◆ $activeDomain

string null Wikimedia\Rdbms\MySQLPrimaryPos::$activeDomain
private

Active GTID domain ID.

Definition at line 30 of file MySQLPrimaryPos.php.

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

◆ $activeServerId

string null Wikimedia\Rdbms\MySQLPrimaryPos::$activeServerId
private

ID of the server were DB writes originate.

Definition at line 32 of file MySQLPrimaryPos.php.

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

◆ $activeServerUUID

string null Wikimedia\Rdbms\MySQLPrimaryPos::$activeServerUUID
private

UUID of the server were DB writes originate.

Definition at line 34 of file MySQLPrimaryPos.php.

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

◆ $asOfTime

float Wikimedia\Rdbms\MySQLPrimaryPos::$asOfTime = 0.0
private

◆ $binLog

string null Wikimedia\Rdbms\MySQLPrimaryPos::$binLog
private

Base name of all Binary Log files.

Definition at line 24 of file MySQLPrimaryPos.php.

Referenced by Wikimedia\Rdbms\MySQLPrimaryPos\getBinlogCoordinates(), and Wikimedia\Rdbms\MySQLPrimaryPos\getLogName().

◆ $gtids

string [] Wikimedia\Rdbms\MySQLPrimaryPos::$gtids = []
private

Map of (server_uuid/gtid_domain_id => GTID)

Definition at line 28 of file MySQLPrimaryPos.php.

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

◆ $logPos

array<int,int|string> null Wikimedia\Rdbms\MySQLPrimaryPos::$logPos
private

Binary Log position tuple (index number, event number)

Definition at line 26 of file MySQLPrimaryPos.php.

Referenced by Wikimedia\Rdbms\MySQLPrimaryPos\getBinlogCoordinates(), and Wikimedia\Rdbms\MySQLPrimaryPos\getLogPosition().

◆ $style

string Wikimedia\Rdbms\MySQLPrimaryPos::$style
private

One of (BINARY_LOG, GTID_MYSQL, GTID_MARIA)

Definition at line 22 of file MySQLPrimaryPos.php.

◆ BINARY_LOG

const Wikimedia\Rdbms\MySQLPrimaryPos::BINARY_LOG = 'binary-log'
private

Definition at line 38 of file MySQLPrimaryPos.php.

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

◆ GTID_MARIA

const Wikimedia\Rdbms\MySQLPrimaryPos::GTID_MARIA = 'gtid-maria'
private

Definition at line 39 of file MySQLPrimaryPos.php.

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

◆ GTID_MYSQL

const Wikimedia\Rdbms\MySQLPrimaryPos::GTID_MYSQL = 'gtid-mysql'
private

Definition at line 40 of file MySQLPrimaryPos.php.

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


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