MediaWiki
master
ILoadBalancer.php
Go to the documentation of this file.
1
<?php
20
namespace
Wikimedia\Rdbms
;
21
113
interface
ILoadBalancer
{
117
public
const
DB_REPLICA
= -1;
123
public
const
DB_PRIMARY
= -2;
124
126
public
const
DOMAIN_ANY
=
''
;
128
public
const
GROUP_GENERIC
=
''
;
129
131
public
const
CONN_TRX_AUTOCOMMIT
= 1;
136
public
const
CONN_UNTRACKED_GAUGE
= 2;
141
public
const
CONN_SILENCE_ERRORS
= 4;
142
161
public
function
getClusterName
(): string;
162
170
public
function
getLocalDomainID
(): string;
171
177
public
function
resolveDomainID
( $domain ): string;
178
189
public
function
setTempTablesOnlyMode
( $value, $domain );
190
204
public
function
getReaderIndex
( $group =
false
);
205
250
public
function
getConnection
( $i, $groups = [], $domain =
false
, $flags = 0 );
251
272
public
function
getServerConnection
( $i, $domain, $flags = 0 );
273
282
public
function
getConnectionRef
( $i, $groups = [], $domain =
false
, $flags = 0 ):
DBConnRef
;
283
292
public
function
getConnectionInternal
( $i, $groups = [], $domain =
false
, $flags = 0 ):
IDatabase
;
293
312
public
function
getMaintenanceConnectionRef
( $i, $groups = [], $domain =
false
, $flags = 0 ):
DBConnRef
;
313
319
public
function
getServerCount
();
320
333
public
function
hasReplicaServers
();
334
351
public
function
hasStreamingReplicaServers
();
352
359
public
function
getServerName
( $i ): string;
360
368
public
function
getServerInfo
( $i );
369
377
public
function
getServerType
( $i );
378
386
public
function
getServerAttributes
( $i );
387
395
public
function
getPrimaryPos
();
396
402
public
function
hasPrimaryChanges
();
403
410
public
function
explicitTrxActive
();
411
420
public
function
hasOrMadeRecentPrimaryChanges
( $age =
null
);
421
426
public
function
getReadOnlyReason
();
427
431
public
function
pingAll
();
432
442
public
function
getMaxLag
();
443
453
public
function
getLagTimes
();
454
466
public
function
waitForPrimaryPos
(
IDatabase
$conn );
467
475
public
function
setTransactionListener
( $name, ?callable $callback =
null
);
476
489
public
function
setTableAliases
( array $aliases );
490
499
public
function
setDomainAliases
( array $aliases );
500
}
Wikimedia\Rdbms\DBConnRef
Helper class used for automatically re-using IDatabase connections and lazily establishing the actual...
Definition
DBConnRef.php:37
Wikimedia\Rdbms\IDatabase
Interface to a relational database.
Definition
IDatabase.php:45
Wikimedia\Rdbms\ILoadBalancer
This class is a delegate to ILBFactory for a given database cluster.
Definition
ILoadBalancer.php:113
Wikimedia\Rdbms\ILoadBalancer\getClusterName
getClusterName()
Get the name of the overall cluster of database servers managing the dataset.
Wikimedia\Rdbms\ILoadBalancer\getMaxLag
getMaxLag()
Get the name and lag time of the most-lagged replica server.
Wikimedia\Rdbms\ILoadBalancer\CONN_UNTRACKED_GAUGE
const CONN_UNTRACKED_GAUGE
Yield an untracked, low-timeout, autocommit-mode handle (to gauge server health)
Definition
ILoadBalancer.php:136
Wikimedia\Rdbms\ILoadBalancer\getConnection
getConnection( $i, $groups=[], $domain=false, $flags=0)
Get a lazy-connecting database handle for a specific or virtual (DB_PRIMARY/DB_REPLICA) server index.
Wikimedia\Rdbms\ILoadBalancer\hasOrMadeRecentPrimaryChanges
hasOrMadeRecentPrimaryChanges( $age=null)
Check if this load balancer object had any recent or still pending writes issued against it by this P...
Wikimedia\Rdbms\ILoadBalancer\getLagTimes
getLagTimes()
Get an estimate of replication lag (in seconds) for each server.
Wikimedia\Rdbms\ILoadBalancer\getServerType
getServerType( $i)
Get the RDBMS type of the server with the specified index (e.g.
Wikimedia\Rdbms\ILoadBalancer\GROUP_GENERIC
const GROUP_GENERIC
The generic query group.
Definition
ILoadBalancer.php:128
Wikimedia\Rdbms\ILoadBalancer\getServerConnection
getServerConnection( $i, $domain, $flags=0)
Get a DB handle for a specific server index.
Wikimedia\Rdbms\ILoadBalancer\getReaderIndex
getReaderIndex( $group=false)
Get the specific server index of the reader connection for a given group.
Wikimedia\Rdbms\ILoadBalancer\DOMAIN_ANY
const DOMAIN_ANY
Domain specifier when no specific database needs to be selected.
Definition
ILoadBalancer.php:126
Wikimedia\Rdbms\ILoadBalancer\DB_REPLICA
const DB_REPLICA
Request a replica DB connection.
Definition
ILoadBalancer.php:117
Wikimedia\Rdbms\ILoadBalancer\CONN_TRX_AUTOCOMMIT
const CONN_TRX_AUTOCOMMIT
Yield a tracked autocommit-mode handle (reuse existing ones)
Definition
ILoadBalancer.php:131
Wikimedia\Rdbms\ILoadBalancer\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
Wikimedia\Rdbms\ILoadBalancer\CONN_SILENCE_ERRORS
const CONN_SILENCE_ERRORS
Yield null on connection failure instead of throwing an exception.
Definition
ILoadBalancer.php:141
Wikimedia\Rdbms\ILoadBalancer\setTempTablesOnlyMode
setTempTablesOnlyMode( $value, $domain)
Indicate whether the tables on this domain are only temporary tables for testing.
Wikimedia\Rdbms\ILoadBalancer\resolveDomainID
resolveDomainID( $domain)
Wikimedia\Rdbms\ILoadBalancer\setDomainAliases
setDomainAliases(array $aliases)
Convert certain database domains to alternative ones.
Wikimedia\Rdbms\ILoadBalancer\getServerCount
getServerCount()
Get the number of servers defined in configuration.
Wikimedia\Rdbms\ILoadBalancer\getLocalDomainID
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
Wikimedia\Rdbms\ILoadBalancer\getServerInfo
getServerInfo( $i)
Return the server configuration map for the server with the specified index.
Wikimedia\Rdbms\ILoadBalancer\waitForPrimaryPos
waitForPrimaryPos(IDatabase $conn)
Wait for a replica DB to reach a specified primary position.
Wikimedia\Rdbms\ILoadBalancer\getConnectionRef
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Wikimedia\Rdbms\ILoadBalancer\setTransactionListener
setTransactionListener( $name, ?callable $callback=null)
Set a callback via IDatabase::setTransactionListener() on all current and future primary connections ...
Wikimedia\Rdbms\ILoadBalancer\hasPrimaryChanges
hasPrimaryChanges()
Whether there are pending changes or callbacks in a transaction by this thread.
Wikimedia\Rdbms\ILoadBalancer\getPrimaryPos
getPrimaryPos()
Get the current primary replication position.
Wikimedia\Rdbms\ILoadBalancer\getMaintenanceConnectionRef
getMaintenanceConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a DB handle, suitable for migrations and schema changes, for a server index.
Wikimedia\Rdbms\ILoadBalancer\explicitTrxActive
explicitTrxActive()
Determine whether an explicit transaction is active on any open primary connection.
Wikimedia\Rdbms\ILoadBalancer\getReadOnlyReason
getReadOnlyReason()
Wikimedia\Rdbms\ILoadBalancer\DB_PRIMARY
const DB_PRIMARY
Request a primary, write-enabled DB connection.
Definition
ILoadBalancer.php:123
Wikimedia\Rdbms\ILoadBalancer\getConnectionInternal
getConnectionInternal( $i, $groups=[], $domain=false, $flags=0)
Wikimedia\Rdbms\ILoadBalancer\hasReplicaServers
hasReplicaServers()
Whether there are any replica servers configured.
Wikimedia\Rdbms\ILoadBalancer\hasStreamingReplicaServers
hasStreamingReplicaServers()
Whether any replica servers use streaming replication from the primary server.
Wikimedia\Rdbms\ILoadBalancer\pingAll
pingAll()
Wikimedia\Rdbms\ILoadBalancer\getServerName
getServerName( $i)
Get the readable name of the server with the specified index.
Wikimedia\Rdbms\ILoadBalancer\getServerAttributes
getServerAttributes( $i)
Get basic attributes of the server with the specified index without connecting.
Wikimedia\Rdbms
Definition
ChangedTablesTracker.php:3
includes
libs
rdbms
loadbalancer
ILoadBalancer.php
Generated on Sat Apr 5 2025 17:25:06 for MediaWiki by
1.10.0