MediaWiki  1.29.1
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 ( $file, $pos, $gtid='')
 
 __toString ()
 
 asOfTime ()
 
 channelsMatch (DBMasterPos $pos)
 
 hasReached (DBMasterPos $pos)
 

Public Attributes

float $asOfTime = 0.0
 UNIX timestamp. More...
 
string $file
 Binlog file. More...
 
string[] $gtids = []
 GTID list. More...
 
int $pos
 Binglog file position. More...
 

Protected Member Functions

 getBinlogCoordinates ()
 
 getGtidCoordinates ()
 

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

Definition at line 15 of file MySQLMasterPos.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\MySQLMasterPos::__construct (   $file,
  $pos,
  $gtid = '' 
)
Parameters
string$fileBinlog file name
integer$posBinlog position
string$gtidComma separated GTID set [optional]

Definition at line 30 of file MySQLMasterPos.php.

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

Member Function Documentation

◆ __toString()

Wikimedia\Rdbms\MySQLMasterPos::__toString ( )
Returns
string <binlog file>="">/<position>, e.g db1034-bin.000976/843431247

Implements Wikimedia\Rdbms\DBMasterPos.

Definition at line 40 of file MySQLMasterPos.php.

◆ asOfTime()

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

Implements Wikimedia\Rdbms\DBMasterPos.

Definition at line 44 of file MySQLMasterPos.php.

References Wikimedia\Rdbms\MySQLMasterPos\$asOfTime.

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

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

References Wikimedia\Rdbms\MySQLMasterPos\$pos, Wikimedia\Rdbms\MySQLMasterPos\getBinlogCoordinates(), and Wikimedia\Rdbms\MySQLMasterPos\getGtidCoordinates().

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

◆ getBinlogCoordinates()

Wikimedia\Rdbms\MySQLMasterPos::getBinlogCoordinates ( )
protected

◆ getGtidCoordinates()

Wikimedia\Rdbms\MySQLMasterPos::getGtidCoordinates ( )
protected
Note
: this returns false for multi-source replication GTID sets
See also
https://mariadb.com/kb/en/mariadb/gtid
https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-concepts.html
Returns
array Map of (domain => integer position) or false

Definition at line 104 of file MySQLMasterPos.php.

References as.

Referenced by Wikimedia\Rdbms\MySQLMasterPos\channelsMatch(), and Wikimedia\Rdbms\MySQLMasterPos\hasReached().

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

References Wikimedia\Rdbms\MySQLMasterPos\$pos, as, Wikimedia\Rdbms\MySQLMasterPos\getBinlogCoordinates(), and Wikimedia\Rdbms\MySQLMasterPos\getGtidCoordinates().

Referenced by DatabaseMysqlBaseTest\testHasReached().

Member Data Documentation

◆ $asOfTime

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

UNIX timestamp.

Definition at line 23 of file MySQLMasterPos.php.

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

◆ $file

string Wikimedia\Rdbms\MySQLMasterPos::$file

Binlog file.

Definition at line 17 of file MySQLMasterPos.php.

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

◆ $gtids

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

GTID list.

Definition at line 21 of file MySQLMasterPos.php.

◆ $pos

int Wikimedia\Rdbms\MySQLMasterPos::$pos

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