MediaWiki REL1_39
ILBFactory.php
Go to the documentation of this file.
1<?php
20namespace Wikimedia\Rdbms;
21
22use Generator;
23use InvalidArgumentException;
24
31interface ILBFactory {
33 public const SHUTDOWN_NORMAL = 0;
35 public const SHUTDOWN_NO_CHRONPROT = 1;
36
38 public const CLUSTER_MAIN_DEFAULT = 'DEFAULT';
39
65 public function __construct( array $conf );
66
74 public function destroy();
75
83 public function getLocalDomainID();
84
90 public function resolveDomainID( $domain );
91
102 public function redefineLocalDomain( $domain );
103
121 public function newMainLB( $domain = false ): ILoadBalancerForOwner;
122
134 public function getMainLB( $domain = false ): ILoadBalancer;
135
151 public function newExternalLB( $cluster ): ILoadBalancerForOwner;
152
162 public function getExternalLB( $cluster ): ILoadBalancer;
163
174 public function getAllMainLBs(): array;
175
184 public function getAllExternalLBs(): array;
185
197 public function forEachLB( $callback, array $params = [] );
198
205 public function getAllLBs();
206
215 public function shutdown(
216 $flags = self::SHUTDOWN_NORMAL,
217 callable $workCallback = null,
218 &$cpIndex = null,
219 &$cpClientId = null
220 );
221
231 public function flushReplicaSnapshots( $fname = __METHOD__ );
232
246 public function commitAll( $fname = __METHOD__, array $options = [] );
247
264 public function beginPrimaryChanges( $fname = __METHOD__ );
265
277 public function commitPrimaryChanges( $fname = __METHOD__, array $options = [] );
278
287 public function rollbackPrimaryChanges( $fname = __METHOD__ );
288
300 public function flushPrimarySessions( $fname = __METHOD__ );
301
308 public function hasTransactionRound();
309
318 public function isReadyForRoundOperations();
319
328 public function hasPrimaryChanges();
329
337 public function laggedReplicaUsed();
338
347 public function hasOrMadeRecentPrimaryChanges( $age = null );
348
374 public function waitForReplication( array $opts = [] );
375
384 public function setWaitForReplicationListener( $name, callable $callback = null );
385
392 public function getEmptyTransactionTicket( $fname );
393
408 public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] );
409
416 public function getChronologyProtectorTouched( $domain = false );
417
424
431 public function setLocalDomainPrefix( $prefix );
432
438 public function closeAll( $fname = __METHOD__ );
439
443 public function setAgentName( $agent );
444
454 public function appendShutdownCPIndexAsQuery( $url, $index );
455
463
473 public function setRequestInfo( array $info );
474
482 public function setDefaultReplicationWaitTimeout( $seconds );
483
497 public function setTableAliases( array $aliases );
498
511 public function setIndexAliases( array $aliases );
512
521 public function setDomainAliases( array $aliases );
522
530}
Detect high-contention DB queries via profiling calls.
Manager of ILoadBalancer objects, and indirectly of IDatabase connections.
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
redefineLocalDomain( $domain)
Close all connections and redefine the local database domain.
beginPrimaryChanges( $fname=__METHOD__)
Flush any primary transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
getAllExternalLBs()
Get the tracked load balancer instances for all external clusters.
commitAll( $fname=__METHOD__, array $options=[])
Commit open transactions on all connections.
setRequestInfo(array $info)
Inject HTTP request header/cookie information during setup of this instance.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
newMainLB( $domain=false)
Create a new load balancer instance for the main cluster that handles the given domain.
commitPrimaryChanges( $fname=__METHOD__, array $options=[])
Commit changes and clear view snapshots on all primary connections.
setLocalDomainPrefix( $prefix)
Set a new table prefix for the existing local domain ID for testing.
hasPrimaryChanges()
Determine if any primary connection has pending changes.
waitForReplication(array $opts=[])
Waits for the replica DBs to catch up to the current primary position.
rollbackPrimaryChanges( $fname=__METHOD__)
Rollback changes on all primary connections.
closeAll( $fname=__METHOD__)
Close all connections on instantiated tracked load balancer instances.
commitAndWaitForReplication( $fname, $ticket, array $opts=[])
Call commitPrimaryChanges() and waitForReplication() if $ticket indicates it is safe.
flushPrimarySessions( $fname=__METHOD__)
Release important session-level state (named lock, table locks) as post-rollback cleanup.
__construct(array $conf)
Sub-classes may extend the required keys in $conf with additional parameters.
shutdown( $flags=self::SHUTDOWN_NORMAL, callable $workCallback=null, &$cpIndex=null, &$cpClientId=null)
Prepare all instantiated tracked load balancer instances for shutdown.
destroy()
Close all connections and make further attempts to open connections result in DBAccessError.
laggedReplicaUsed()
Determine if any lagged replica DB connection was used.
getChronologyProtectorClientId()
Get the client ID of the ChronologyProtector instance.
getAllLBs()
Get all tracked load balancer instances (generator)
setDomainAliases(array $aliases)
Convert certain database domains to alternative ones.
getExternalLB( $cluster)
Get the tracked load balancer instance for an external cluster.
getMainLB( $domain=false)
Get the tracked load balancer instance for the main cluster that handles the given domain.
disableChronologyProtection()
Disable the ChronologyProtector on all instantiated tracked load balancer instances.
setDefaultReplicationWaitTimeout( $seconds)
Set the default timeout for replication wait checks.
const SHUTDOWN_NO_CHRONPROT
Do not save "session consistency" DB replication positions.
hasTransactionRound()
Check if an explicit transaction round is active.
const SHUTDOWN_NORMAL
Idiom for "no special shutdown flags".
getAllMainLBs()
Get the tracked load balancer instances for all main clusters.
forEachLB( $callback, array $params=[])
Execute a function for each instantiated tracked load balancer instance.
getTransactionProfiler()
Get the TransactionProfiler used by this instance.
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
appendShutdownCPIndexAsQuery( $url, $index)
Append ?cpPosIndex parameter to a URL for ChronologyProtector purposes if needed.
getChronologyProtectorTouched( $domain=false)
Get the UNIX timestamp when the client last touched the DB, if they did so recently.
hasOrMadeRecentPrimaryChanges( $age=null)
Determine if any primary connection has pending/written changes from this request.
getEmptyTransactionTicket( $fname)
Get a token asserting that no transaction writes are active on tracked load balancers.
newExternalLB( $cluster)
Create a new load balancer instance for an external cluster.
isReadyForRoundOperations()
Check if transaction rounds can be started, committed, or rolled back right now.
flushReplicaSnapshots( $fname=__METHOD__)
Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot.
setWaitForReplicationListener( $name, callable $callback=null)
Add a callback to be run in every call to waitForReplication() before waiting.
Internal interface for LoadBalancer methods used by LBFactory.
Create and track the database connections and transactions for a given database cluster.