MediaWiki REL1_35
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)
 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.
 
 unserialize ( $serialized)
 

Static Public Member Functions

static getRelevantActiveGTIDs (MySQLMasterPos $pos, MySQLMasterPos $refPos)
 

Protected Member Functions

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

Static Protected Member Functions

static parseGTID ( $id)
 

Private Attributes

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

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 352 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.

◆ getActiveGtidCoordinates()

◆ getBinlogCoordinates()

Wikimedia\Rdbms\MySQLMasterPos::getBinlogCoordinates ( )
protected

◆ getGTIDs()

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

Definition at line 189 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.

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.

◆ 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.

◆ getRelevantActiveGTIDs()

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

Definition at line 251 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\getActiveGtidCoordinates().

◆ 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 Wikimedia\Rdbms\MySQLMasterPos\getActiveGtidCoordinates(), and Wikimedia\Rdbms\MySQLMasterPos\getBinlogCoordinates().

◆ 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 294 of file MySQLMasterPos.php.

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

◆ serialize()

◆ setActiveDomain()

Wikimedia\Rdbms\MySQLMasterPos::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
MySQLMasterPos::getRelevantActiveGTIDs()
https://mariadb.com/kb/en/library/gtid/#gtid_domain_id
Parameters
int | null$id@gtid_domain_id of the active replication stream
Returns
MySQLMasterPos This instance (since 1.34)
Since
1.31

Definition at line 205 of file MySQLMasterPos.php.

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

◆ setActiveOriginServerId()

Wikimedia\Rdbms\MySQLMasterPos::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
MySQLMasterPos::getRelevantActiveGTIDs()
Parameters
int | null$id@server_id of the server were writes originate
Returns
MySQLMasterPos This instance (since 1.34)
Since
1.31

Definition at line 222 of file MySQLMasterPos.php.

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

◆ setActiveOriginServerUUID()

Wikimedia\Rdbms\MySQLMasterPos::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
MySQLMasterPos::getRelevantActiveGTIDs()
Parameters
string | null$id@server_uuid of the server were writes originate
Returns
MySQLMasterPos This instance (since 1.34)
Since
1.31

Definition at line 239 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

string 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'
private

Definition at line 37 of file MySQLMasterPos.php.

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

◆ GTID_MARIA

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

Definition at line 38 of file MySQLMasterPos.php.

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

◆ GTID_MYSQL

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

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: