MediaWiki  1.33.0
Wikimedia\Rdbms\MySQLMasterPos Class Reference

DBMasterPos class for MySQL/MariaDB. More...

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

Public Member Functions

 __construct ( $position, $asOfTime)
 
 __toString ()
 
 asOfTime ()
 
 channelsMatch (DBMasterPos $pos)
 
 getGTIDs ()
 
 getLogFile ()
 
 getLogName ()
 
 getLogPosition ()
 
 hasReached (DBMasterPos $pos)
 
 serialize ()
 
 setActiveDomain ( $id)
 
 setActiveOriginServerId ( $id)
 
 setActiveOriginServerUUID ( $id)
 
 unserialize ( $serialized)
 

Static Public Member Functions

static getCommonDomainGTIDs (MySQLMasterPos $pos, MySQLMasterPos $refPos)
 

Public Attributes

const BINARY_LOG = 'binary-log'
 
const GTID_MARIA = 'gtid-maria'
 
const GTID_MYSQL = 'gtid-mysql'
 

Protected Member Functions

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

Static Protected Member Functions

static parseGTID ( $id)
 

Private Attributes

int null $activeDomain
 Active GTID domain ID. More...
 
int 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...
 
int[] null $logPos
 Binary Log position tuple (index number, event number) More...
 
int $style
 One of (BINARY_LOG, GTID_MYSQL, GTID_MARIA) More...
 

Detailed Description

DBMasterPos class for MySQL/MariaDB.

Note that master 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

Definition at line 19 of file MySQLMasterPos.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 50 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\$asOfTime, and Wikimedia\Rdbms\MySQLMasterPos\init().

Member Function Documentation

◆ __toString()

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

Implements Wikimedia\Rdbms\DBMasterPos.

Definition at line 321 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\getLogFile().

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

◆ asOfTime()

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

Implements Wikimedia\Rdbms\DBMasterPos.

Definition at line 99 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\$asOfTime.

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

◆ channelsMatch()

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

Implements Wikimedia\Rdbms\DBMasterPos.

Definition at line 137 of file MySQLMasterPos.php.

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

Referenced by DatabaseMysqlBaseTest\testChannelsMatch(), and DatabaseMysqlBaseTest\testHasReached().

◆ getActiveGtidCoordinates()

◆ getBinlogCoordinates()

Wikimedia\Rdbms\MySQLMasterPos::getBinlogCoordinates ( )
protected

◆ getCommonDomainGTIDs()

static Wikimedia\Rdbms\MySQLMasterPos::getCommonDomainGTIDs ( MySQLMasterPos  $pos,
MySQLMasterPos  $refPos 
)
static
Parameters
MySQLMasterPos$pos
MySQLMasterPos$refPos
Returns
string[] List of GTIDs from $pos that have domains in $refPos
Since
1.31

Definition at line 222 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\getActiveGtidCoordinates().

Referenced by Wikimedia\Rdbms\DatabaseMysqlBase\masterPosWait().

◆ getGTIDs()

Wikimedia\Rdbms\MySQLMasterPos::getGTIDs ( )
Returns
string[] Map of (server_uuid/gtid_domain_id => GTID)
Since
1.31

Definition at line 188 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\$gtids.

◆ getLogFile()

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

Definition at line 180 of file MySQLMasterPos.php.

References null.

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

◆ getLogName()

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

Definition at line 164 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\$binLog, and null.

◆ getLogPosition()

Wikimedia\Rdbms\MySQLMasterPos::getLogPosition ( )
Returns
int[]|null Tuple of (binary log file number, event number)
Since
1.31

Definition at line 172 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\$logPos, and null.

◆ hasReached()

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

Implements Wikimedia\Rdbms\DBMasterPos.

Definition at line 103 of file MySQLMasterPos.php.

References as, Wikimedia\Rdbms\MySQLMasterPos\getActiveGtidCoordinates(), and Wikimedia\Rdbms\MySQLMasterPos\getBinlogCoordinates().

Referenced by DatabaseMysqlBaseTest\testHasReached().

◆ init()

◆ parseGTID()

static Wikimedia\Rdbms\MySQLMasterPos::parseGTID (   $id)
staticprotected
Parameters
string$idGTID
Returns
array|null [domain ID or server UUID, sequence number, server ID/UUID] or null

Definition at line 263 of file MySQLMasterPos.php.

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

◆ serialize()

Wikimedia\Rdbms\MySQLMasterPos::serialize ( )

◆ setActiveDomain()

Wikimedia\Rdbms\MySQLMasterPos::setActiveDomain (   $id)
Parameters
int | null$id@gtid_domain_id of the active replication stream
Since
1.31

Definition at line 196 of file MySQLMasterPos.php.

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

◆ setActiveOriginServerId()

Wikimedia\Rdbms\MySQLMasterPos::setActiveOriginServerId (   $id)
Parameters
int | null$id@server_id of the server were writes originate
Since
1.31

Definition at line 204 of file MySQLMasterPos.php.

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

◆ setActiveOriginServerUUID()

Wikimedia\Rdbms\MySQLMasterPos::setActiveOriginServerUUID (   $id)
Parameters
string | null$id@server_uuid of the server were writes originate
Since
1.31

Definition at line 212 of file MySQLMasterPos.php.

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

◆ unserialize()

Member Data Documentation

◆ $activeDomain

int null Wikimedia\Rdbms\MySQLMasterPos::$activeDomain
private

Active GTID domain ID.

Definition at line 29 of file MySQLMasterPos.php.

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

◆ $activeServerId

int null Wikimedia\Rdbms\MySQLMasterPos::$activeServerId
private

ID of the server were DB writes originate.

Definition at line 31 of file MySQLMasterPos.php.

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

◆ $activeServerUUID

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

UUID of the server were DB writes originate.

Definition at line 33 of file MySQLMasterPos.php.

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

◆ $asOfTime

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

◆ $binLog

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

Base name of all Binary Log files.

Definition at line 23 of file MySQLMasterPos.php.

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

◆ $gtids

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

Map of (server_uuid/gtid_domain_id => GTID)

Definition at line 27 of file MySQLMasterPos.php.

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

◆ $logPos

int [] null Wikimedia\Rdbms\MySQLMasterPos::$logPos
private

Binary Log position tuple (index number, event number)

Definition at line 25 of file MySQLMasterPos.php.

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

◆ $style

int Wikimedia\Rdbms\MySQLMasterPos::$style
private

One of (BINARY_LOG, GTID_MYSQL, GTID_MARIA)

Definition at line 21 of file MySQLMasterPos.php.

◆ BINARY_LOG

const Wikimedia\Rdbms\MySQLMasterPos::BINARY_LOG = 'binary-log'

Definition at line 37 of file MySQLMasterPos.php.

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

◆ GTID_MARIA

const Wikimedia\Rdbms\MySQLMasterPos::GTID_MARIA = 'gtid-maria'

Definition at line 38 of file MySQLMasterPos.php.

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

◆ GTID_MYSQL

const Wikimedia\Rdbms\MySQLMasterPos::GTID_MYSQL = 'gtid-mysql'

Definition at line 39 of file MySQLMasterPos.php.

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


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