MediaWiki
1.30.0
|
Class for ensuring a consistent ordering of events as seen by the user, despite replication. More...
Public Member Functions | |
__construct (BagOStuff $store, array $client, $posTime=null) | |
getTouched ( $dbName) | |
initLB (ILoadBalancer $lb) | |
Initialise a ILoadBalancer to give it appropriate chronology protection. More... | |
setEnabled ( $enabled) | |
setLogger (LoggerInterface $logger) | |
setWaitEnabled ( $enabled) | |
shutdown (callable $workCallback=null, $mode='sync') | |
Notify the ChronologyProtector that the LBFactory is done calling shutdownLB() for now. More... | |
shutdownLB (ILoadBalancer $lb) | |
Notify the ChronologyProtector that the ILoadBalancer is about to shut down. More... | |
Protected Member Functions | |
initPositions () | |
Load in previous master positions for the client. More... | |
Protected Attributes | |
string | $clientId |
Hash of client parameters. More... | |
bool | $enabled = true |
Whether to no-op all method calls. More... | |
bool | $initialized = false |
Whether the client data was loaded. More... | |
string | $key |
Storage key name. More... | |
LoggerInterface | $logger |
DBMasterPos[] | $shutdownPositions = [] |
Map of (DB master name => position) More... | |
float[] | $shutdownTouchDBs = [] |
Map of (DB master name => 1) More... | |
DBMasterPos[] | $startupPositions = [] |
Map of (DB master name => position) More... | |
BagOStuff | $store |
bool | $wait = true |
Whether to check and wait on positions. More... | |
float null | $waitForPosTime |
Minimum UNIX timestamp of 1+ expected startup positions. More... | |
int | $waitForPosTimeout = self::POS_WAIT_TIMEOUT |
Max seconds to wait on positions to appear. More... | |
Private Member Functions | |
getTouchedKey (BagOStuff $store, $dbName) | |
Static Private Member Functions | |
static | mergePositions ( $curValue, array $shutdownPositions) |
static | minPosTime ( $data) |
Class for ensuring a consistent ordering of events as seen by the user, despite replication.
Kind of like Hawking's [[Chronology Protection Agency]].
Definition at line 36 of file ChronologyProtector.php.
Wikimedia\Rdbms\ChronologyProtector::__construct | ( | BagOStuff | $store, |
array | $client, | ||
$posTime = null |
|||
) |
BagOStuff | $store | |
array | $client | Map of (ip: <IP>, agent: <user-agent>) |
float | $posTime | UNIX timestamp |
Definition at line 75 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$store, key, BagOStuff\makeGlobalKey(), and store.
Wikimedia\Rdbms\ChronologyProtector::getTouched | ( | $dbName | ) |
string | $dbName | DB master name (e.g. "db1052") |
Definition at line 234 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\getTouchedKey(), and store.
|
private |
BagOStuff | $store | |
string | $dbName |
Definition at line 243 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$store, and BagOStuff\makeGlobalKey().
Referenced by Wikimedia\Rdbms\ChronologyProtector\getTouched(), and Wikimedia\Rdbms\ChronologyProtector\shutdown().
Wikimedia\Rdbms\ChronologyProtector::initLB | ( | ILoadBalancer | $lb | ) |
Initialise a ILoadBalancer to give it appropriate chronology protection.
If the stash has a previous master position recorded, this will try to make sure that the next query to a replica DB of that master will see changes up to that position by delaying execution. The delay may timeout and allow stale data if no non-lagged replica DBs are available.
ILoadBalancer | $lb |
Definition at line 114 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ILoadBalancer\getServerCount(), Wikimedia\Rdbms\ILoadBalancer\getServerName(), Wikimedia\Rdbms\ILoadBalancer\getWriterIndex(), Wikimedia\Rdbms\ChronologyProtector\initPositions(), and Wikimedia\Rdbms\ILoadBalancer\waitFor().
|
protected |
Load in previous master positions for the client.
Definition at line 250 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$waitForPosTimeout, key, store, and use.
Referenced by Wikimedia\Rdbms\ChronologyProtector\initLB().
|
staticprivate |
array | bool | $curValue | |
DBMasterPos[] | $shutdownPositions |
Definition at line 317 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$shutdownPositions, and as.
|
staticprivate |
array | bool | $data |
Definition at line 297 of file ChronologyProtector.php.
References as.
Wikimedia\Rdbms\ChronologyProtector::setEnabled | ( | $enabled | ) |
bool | $enabled | Whether to no-op all method calls |
Definition at line 91 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$enabled.
Wikimedia\Rdbms\ChronologyProtector::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 83 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$logger.
Wikimedia\Rdbms\ChronologyProtector::setWaitEnabled | ( | $enabled | ) |
bool | $enabled | Whether to check and wait on positions |
Definition at line 99 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$enabled.
Wikimedia\Rdbms\ChronologyProtector::shutdown | ( | callable | $workCallback = null , |
$mode = 'sync' |
|||
) |
Notify the ChronologyProtector that the LBFactory is done calling shutdownLB() for now.
May commit chronology data to persistent storage.
callable | null | $workCallback | Work to do instead of waiting on syncing positions |
string | $mode | One of (sync, async); whether to wait on remote datacenters |
Definition at line 166 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ChronologyProtector\$shutdownPositions, Wikimedia\Rdbms\ChronologyProtector\$store, BagOStuff\addBusyCallback(), as, captcha-old\count, BagOStuff\get(), BagOStuff\getQoS(), Wikimedia\Rdbms\ChronologyProtector\getTouchedKey(), key, BagOStuff\lock(), BagOStuff\set(), store, and BagOStuff\unlock().
Referenced by Wikimedia\Rdbms\LBFactory\shutdownChronologyProtector().
Wikimedia\Rdbms\ChronologyProtector::shutdownLB | ( | ILoadBalancer | $lb | ) |
Notify the ChronologyProtector that the ILoadBalancer is about to shut down.
Saves replication positions.
ILoadBalancer | $lb |
Definition at line 139 of file ChronologyProtector.php.
References Wikimedia\Rdbms\ILoadBalancer\getMasterPos(), Wikimedia\Rdbms\ILoadBalancer\getServerCount(), Wikimedia\Rdbms\ILoadBalancer\getServerName(), Wikimedia\Rdbms\ILoadBalancer\getWriterIndex(), and Wikimedia\Rdbms\ILoadBalancer\hasOrMadeRecentMasterChanges().
Referenced by Wikimedia\Rdbms\LBFactory\shutdownChronologyProtector().
|
protected |
Hash of client parameters.
Definition at line 45 of file ChronologyProtector.php.
|
protected |
Whether to no-op all method calls.
Definition at line 51 of file ChronologyProtector.php.
Referenced by Wikimedia\Rdbms\ChronologyProtector\setEnabled(), and Wikimedia\Rdbms\ChronologyProtector\setWaitEnabled().
|
protected |
Whether the client data was loaded.
Definition at line 56 of file ChronologyProtector.php.
|
protected |
Storage key name.
Definition at line 43 of file ChronologyProtector.php.
|
protected |
Definition at line 40 of file ChronologyProtector.php.
Referenced by Wikimedia\Rdbms\ChronologyProtector\setLogger().
|
protected |
Map of (DB master name => position)
Definition at line 60 of file ChronologyProtector.php.
Referenced by Wikimedia\Rdbms\ChronologyProtector\mergePositions(), and Wikimedia\Rdbms\ChronologyProtector\shutdown().
|
protected |
Map of (DB master name => 1)
Definition at line 62 of file ChronologyProtector.php.
|
protected |
Map of (DB master name => position)
Definition at line 58 of file ChronologyProtector.php.
|
protected |
Definition at line 38 of file ChronologyProtector.php.
Referenced by Wikimedia\Rdbms\ChronologyProtector\__construct(), Wikimedia\Rdbms\ChronologyProtector\getTouchedKey(), and Wikimedia\Rdbms\ChronologyProtector\shutdown().
|
protected |
Whether to check and wait on positions.
Definition at line 53 of file ChronologyProtector.php.
|
protected |
Minimum UNIX timestamp of 1+ expected startup positions.
Definition at line 47 of file ChronologyProtector.php.
|
protected |
Max seconds to wait on positions to appear.
Definition at line 49 of file ChronologyProtector.php.
Referenced by Wikimedia\Rdbms\ChronologyProtector\initPositions().