Go to the documentation of this file.
53 if ( !isset(
$params[
'servers'] ) ) {
54 throw new MWException( __CLASS__ .
': missing servers parameter' );
56 $this->mServers =
$params[
'servers'];
58 if ( isset(
$params[
'waitTimeout'] ) ) {
59 $this->mWaitTimeout =
$params[
'waitTimeout'];
61 $this->mWaitTimeout = 10;
64 $this->mReadIndex = -1;
65 $this->mWriteIndex = -1;
66 $this->mConns =
array(
68 'foreignUsed' =>
array(),
69 'foreignFree' =>
array() );
70 $this->mLoads =
array();
71 $this->mWaitForPos =
false;
72 $this->mLaggedSlaveMode =
false;
73 $this->mErrorConnection =
false;
74 $this->mAllowLagged =
false;
76 if ( isset(
$params[
'loadMonitor'] ) ) {
77 $this->mLoadMonitorClass =
$params[
'loadMonitor'];
79 $master = reset(
$params[
'servers'] );
80 if ( isset( $master[
'type'] ) && $master[
'type'] ===
'mysql' ) {
81 $this->mLoadMonitorClass =
'LoadMonitorMySQL';
83 $this->mLoadMonitorClass =
'LoadMonitorNull';
87 foreach (
$params[
'servers']
as $i => $server ) {
88 $this->mLoads[$i] = $server[
'load'];
89 if ( isset( $server[
'groupLoads'] ) ) {
90 foreach ( $server[
'groupLoads']
as $group => $ratio ) {
91 if ( !isset( $this->mGroupLoads[$group] ) ) {
92 $this->mGroupLoads[$group] =
array();
94 $this->mGroupLoads[$group][$i] = $ratio;
106 if ( !isset( $this->mLoadMonitor ) ) {
108 $this->mLoadMonitor =
new $class( $this );
120 return wfSetVar( $this->mParentInfo, $x );
142 # Unset excessively lagged servers
144 foreach ( $lags
as $i => $lag ) {
146 if ( $lag ===
false ) {
147 wfDebugLog(
'replication',
"Server #$i is not replicating" );
149 } elseif ( isset( $this->mServers[$i][
'max lag'] ) && $lag > $this->mServers[$i][
'max lag'] ) {
150 wfDebugLog(
'replication',
"Server #$i is excessively lagged ($lag seconds)" );
156 # Find out if all the slaves with non-zero load are lagged
158 foreach ( $loads
as $load ) {
162 # No appropriate DB servers except maybe the master and some slaves with zero load
163 # Do NOT use the master
164 # Instead, this function will return false, triggering read-only mode,
165 # and a lagged slave will be used instead.
169 if ( count( $loads ) == 0 ) {
173 #wfDebugLog( 'connect', var_export( $loads, true ) );
175 # Return a random representative of the remainder
191 global $wgReadOnly, $wgDBtype;
193 # @todo FIXME: For now, only go through all this for mysql databases
194 if ( $wgDBtype !=
'mysql' ) {
198 if ( count( $this->mServers ) == 1 ) {
199 # Skip the load balancing if there's only one server
201 } elseif ( $group ===
false && $this->mReadIndex >= 0 ) {
202 # Shortcut if generic reader exists already
208 # Find the relevant load array
209 if ( $group !==
false ) {
210 if ( isset( $this->mGroupLoads[$group] ) ) {
211 $nonErrorLoads = $this->mGroupLoads[$group];
213 # No loads for this group, return false and the caller can use some other group
214 wfDebug( __METHOD__ .
": no loads for group $group\n" );
222 if ( !count( $nonErrorLoads ) ) {
223 throw new MWException(
"Empty server array given to LoadBalancer" );
226 # Scale the configured load ratios according to the dynamic load (if the load monitor supports it)
227 $this->
getLoadMonitor()->scaleLoads( $nonErrorLoads, $group, $wiki );
229 $laggedSlaveMode =
false;
231 # No server found yet
233 # First try quickly looking through the available servers for a server that
235 $currentLoads = $nonErrorLoads;
236 while ( count( $currentLoads ) ) {
237 if ( $wgReadOnly || $this->mAllowLagged || $laggedSlaveMode ) {
241 if ( $i ===
false && count( $currentLoads ) != 0 ) {
242 # All slaves lagged. Switch to read-only mode
243 wfDebugLog(
'replication',
"All slaves lagged. Switch to read-only mode" );
244 $wgReadOnly =
'The database has been automatically locked ' .
245 'while the slave database servers catch up to the master';
247 $laggedSlaveMode =
true;
251 if ( $i ===
false ) {
252 # pickRandom() returned false
253 # This is permanent and means the configuration or the load monitor
254 # wants us to return false.
255 wfDebugLog(
'connect', __METHOD__ .
": pickRandom() returned false" );
261 ": Using reader #$i: {$this->mServers[$i]['host']}..." );
265 wfDebugLog(
'connect', __METHOD__ .
": Failed connecting to $i/$wiki" );
266 unset( $nonErrorLoads[$i] );
267 unset( $currentLoads[$i] );
274 if ( $wiki !==
false ) {
282 # If all servers were down, quit now
283 if ( !count( $nonErrorLoads ) ) {
287 if ( $i !==
false ) {
288 # Slave connection successful
289 # Wait for the session master pos for a short time
290 if ( $this->mWaitForPos && $i > 0 ) {
291 if ( !$this->
doWait( $i ) ) {
292 $this->mServers[$i][
'slave pos'] = $conn->getSlavePos();
295 if ( $this->mReadIndex <= 0 && $this->mLoads[$i] > 0 && $group !==
false ) {
296 $this->mReadIndex = $i;
310 wfDebug( __METHOD__ .
": waiting $t us\n" );
323 public function waitFor( $pos ) {
325 $this->mWaitForPos = $pos;
329 if ( !$this->
doWait( $i ) ) {
331 $this->mLaggedSlaveMode =
true;
343 $this->mWaitForPos = $pos;
344 $serverCount = count( $this->mServers );
345 for ( $i = 1; $i < $serverCount; $i++ ) {
346 if ( $this->mLoads[$i] > 0 ) {
347 $this->
doWait( $i,
true );
361 foreach ( $this->mConns
as $conns ) {
362 if ( !empty( $conns[$i] ) ) {
363 return reset( $conns[$i] );
376 protected function doWait( $index, $open =
false ) {
377 # Find a connection to wait on
381 wfDebug( __METHOD__ .
": no connection open\n" );
387 wfDebug( __METHOD__ .
": failed to open connection\n" );
394 wfDebug( __METHOD__ .
": Waiting for slave #$index to catch up...\n" );
395 $result = $conn->masterPosWait( $this->mWaitForPos, $this->mWaitTimeout );
398 # Timed out waiting for slave, use master instead
399 wfDebug( __METHOD__ .
": Timed out waiting for slave #$index pos {$this->mWaitForPos}\n" );
403 wfDebug( __METHOD__ .
": Done\n" );
425 throw new MWException(
'Attempt to call ' . __METHOD__ .
426 ' with deprecated server index DB_LAST' );
427 } elseif ( $i ===
null || $i ===
false ) {
429 throw new MWException(
'Attempt to call ' . __METHOD__ .
430 ' with invalid server index' );
440 } elseif ( !is_array( $groups ) ) {
442 if ( $groupIndex !==
false ) {
444 wfDebug( __METHOD__ .
": using server $serverName for group $groups\n" );
448 foreach ( $groups
as $group ) {
450 if ( $groupIndex !==
false ) {
452 wfDebug( __METHOD__ .
": using server $serverName for group $group\n" );
459 # Operation-based index
461 $this->mLastError =
'Unknown error';
463 # Couldn't find a working server in getReaderIndex()?
464 if ( $i ===
false ) {
472 # Now we have an explicit index into the servers array
494 $serverIndex = $conn->getLBInfo(
'serverIndex' );
495 $refCount = $conn->getLBInfo(
'foreignPoolRefCount' );
496 if ( $serverIndex ===
null || $refCount ===
null ) {
497 wfDebug( __METHOD__ .
": this connection was not opened as a foreign connection\n" );
513 $dbName = $conn->getDBname();
514 $prefix = $conn->tablePrefix();
515 if ( strval( $prefix ) !==
'' ) {
516 $wiki =
"$dbName-$prefix";
520 if ( $this->mConns[
'foreignUsed'][$serverIndex][$wiki] !== $conn ) {
521 throw new MWException( __METHOD__ .
": connection not found, has " .
522 "the connection been freed already?" );
524 $conn->setLBInfo(
'foreignPoolRefCount', --$refCount );
525 if ( $refCount <= 0 ) {
526 $this->mConns[
'foreignFree'][$serverIndex][$wiki] = $conn;
527 unset( $this->mConns[
'foreignUsed'][$serverIndex][$wiki] );
528 wfDebug( __METHOD__ .
": freed connection $serverIndex/$wiki\n" );
530 wfDebug( __METHOD__ .
": reference count for $serverIndex/$wiki reduced to $refCount\n" );
582 if ( $wiki !==
false ) {
588 if ( isset( $this->mConns[
'local'][$i][0] ) ) {
589 $conn = $this->mConns[
'local'][$i][0];
591 $server = $this->mServers[$i];
592 $server[
'serverIndex'] = $i;
594 if ( $conn->isOpen() ) {
595 wfDebug(
"Connected to database $i at {$this->mServers[$i]['host']}\n" );
596 $this->mConns[
'local'][$i][0] = $conn;
598 wfDebug(
"Failed to connect to database $i at {$this->mServers[$i]['host']}\n" );
599 $this->mErrorConnection = $conn;
629 if ( isset( $this->mConns[
'foreignUsed'][$i][$wiki] ) ) {
631 $conn = $this->mConns[
'foreignUsed'][$i][$wiki];
632 wfDebug( __METHOD__ .
": reusing connection $i/$wiki\n" );
633 } elseif ( isset( $this->mConns[
'foreignFree'][$i][$wiki] ) ) {
635 $conn = $this->mConns[
'foreignFree'][$i][$wiki];
636 unset( $this->mConns[
'foreignFree'][$i][$wiki] );
637 $this->mConns[
'foreignUsed'][$i][$wiki] = $conn;
638 wfDebug( __METHOD__ .
": reusing free connection $i/$wiki\n" );
639 } elseif ( !empty( $this->mConns[
'foreignFree'][$i] ) ) {
641 $conn = reset( $this->mConns[
'foreignFree'][$i] );
642 $oldWiki =
key( $this->mConns[
'foreignFree'][$i] );
644 if ( !$conn->selectDB( $dbName ) ) {
645 $this->mLastError =
"Error selecting database $dbName on server " .
646 $conn->getServer() .
" from client host " .
wfHostname() .
"\n";
647 $this->mErrorConnection = $conn;
650 $conn->tablePrefix( $prefix );
651 unset( $this->mConns[
'foreignFree'][$i][$oldWiki] );
652 $this->mConns[
'foreignUsed'][$i][$wiki] = $conn;
653 wfDebug( __METHOD__ .
": reusing free connection from $oldWiki for $wiki\n" );
657 $server = $this->mServers[$i];
658 $server[
'serverIndex'] = $i;
659 $server[
'foreignPoolRefCount'] = 0;
660 $server[
'foreign'] =
true;
662 if ( !$conn->isOpen() ) {
663 wfDebug( __METHOD__ .
": error opening connection for $i/$wiki\n" );
664 $this->mErrorConnection = $conn;
667 $conn->tablePrefix( $prefix );
668 $this->mConns[
'foreignUsed'][$i][$wiki] = $conn;
669 wfDebug( __METHOD__ .
": opened new connection for $i/$wiki\n" );
675 $refCount = $conn->getLBInfo(
'foreignPoolRefCount' );
676 $conn->setLBInfo(
'foreignPoolRefCount', $refCount + 1 );
690 function isOpen( $index ) {
691 if ( !is_integer( $index ) ) {
709 if ( !is_array( $server ) ) {
710 throw new MWException(
'You must update your load-balancing configuration. ' .
711 'See DefaultSettings.php entry for $wgDBservers.' );
714 if ( $dbNameOverride !==
false ) {
715 $server[
'dbname'] = $dbNameOverride;
727 $db->setLBInfo( $server );
728 if ( isset( $server[
'fakeSlaveLag'] ) ) {
729 $db->setFakeSlaveLag( $server[
'fakeSlaveLag'] );
731 if ( isset( $server[
'fakeMaster'] ) ) {
732 $db->setFakeMaster(
true );
745 if ( !is_object( $conn ) ) {
747 wfLogDBError(
"LB failure with no last connection. Connection error: {$this->mLastError}" );
752 $server = $conn->getProperty(
'mServer' );
753 wfLogDBError(
"Connection error: {$this->mLastError} ({$server})" );
754 $conn->reportConnectionError(
"{$this->mLastError} ({$server})" );
774 return array_key_exists( $i, $this->mServers );
784 return array_key_exists( $i, $this->mServers ) && $this->mLoads[$i] != 0;
793 return count( $this->mServers );
803 if ( isset( $this->mServers[$i][
'hostName'] ) ) {
804 return $this->mServers[$i][
'hostName'];
805 } elseif ( isset( $this->mServers[$i][
'host'] ) ) {
806 return $this->mServers[$i][
'host'];
818 if ( isset( $this->mServers[$i] ) ) {
819 return $this->mServers[$i];
832 $this->mServers[$i] = $serverInfo;
840 # If this entire request was served from a slave without opening a connection to the
841 # master (however unlikely that may be), then we can fetch the position from the slave.
843 if ( !$masterConn ) {
844 $serverCount = count( $this->mServers );
845 for ( $i = 1; $i < $serverCount; $i++ ) {
848 wfDebug(
"Master pos fetched from slave\n" );
850 return $conn->getSlavePos();
854 wfDebug(
"Master pos fetched from master\n" );
856 return $masterConn->getMasterPos();
866 foreach ( $this->mConns
as $conns2 ) {
867 foreach ( $conns2
as $conns3 ) {
869 foreach ( $conns3
as $conn ) {
874 $this->mConns =
array(
876 'foreignFree' =>
array(),
877 'foreignUsed' =>
array(),
900 foreach ( $this->mConns
as $i1 => $conns2 ) {
901 foreach ( $conns2
as $i2 => $conns3 ) {
902 foreach ( $conns3
as $i3 => $candidateConn ) {
903 if ( $conn === $candidateConn ) {
905 unset( $this->mConns[$i1][$i2][$i3] );
921 foreach ( $this->mConns
as $conns2 ) {
922 foreach ( $conns2
as $conns3 ) {
924 foreach ( $conns3
as $conn ) {
925 if ( $conn->trxLevel() ) {
926 $conn->commit( __METHOD__,
'flush' );
939 foreach ( $this->mConns
as $conns2 ) {
940 if ( empty( $conns2[$masterIndex] ) ) {
944 foreach ( $conns2[$masterIndex]
as $conn ) {
945 if ( $conn->trxLevel() && $conn->writesOrCallbacksPending() ) {
946 $conn->commit( __METHOD__,
'flush' );
959 foreach ( $this->mConns
as $conns2 ) {
960 if ( empty( $conns2[$masterIndex] ) ) {
964 foreach ( $conns2[$masterIndex]
as $conn ) {
965 if ( $conn->trxLevel() && $conn->writesOrCallbacksPending() ) {
966 $conn->rollback( __METHOD__,
'flush' );
981 foreach ( $this->mConns
as $conns2 ) {
982 if ( empty( $conns2[$masterIndex] ) ) {
986 foreach ( $conns2[$masterIndex]
as $conn ) {
987 if ( $conn->trxLevel() && $conn->writesOrCallbacksPending() ) {
1016 if ( $mode ===
null ) {
1019 $this->mAllowLagged = $mode;
1029 foreach ( $this->mConns
as $conns2 ) {
1030 foreach ( $conns2
as $conns3 ) {
1032 foreach ( $conns3
as $conn ) {
1033 if ( !$conn->ping() ) {
1049 foreach ( $this->mConns
as $conns2 ) {
1050 foreach ( $conns2
as $conns3 ) {
1051 foreach ( $conns3
as $conn ) {
1052 $mergedParams = array_merge(
array( $conn ),
$params );
1053 call_user_func_array( $callback, $mergedParams );
1073 foreach ( $this->mServers
as $i => $conn ) {
1075 if ( $wiki ===
false ) {
1084 $lag = $conn->getLag();
1085 if ( $lag > $maxLag ) {
1087 $host = $this->mServers[$i][
'host'];
1093 return array( $host, $maxLag, $maxIndex );
1105 if ( isset( $this->mLagTimes ) ) {
1110 $this->mLagTimes =
array( 0 => 0 );
1112 # Send the request to the load monitor
1114 array_keys( $this->mServers ), $wiki );
1138 return $conn->getLag();
1146 $this->mLagTimes =
null;
1174 $this->conn =
$conn;
1176 $this->params =
$conn;
1181 if ( $this->conn ===
null ) {
1183 $this->conn = $this->lb->getConnection( $db, $groups, $wiki );
1186 return call_user_func_array(
array( $this->conn,
$name ), $arguments );
1190 if ( $this->conn !==
null ) {
1191 $this->lb->reuseConnection( $this->conn );
isOpen( $index)
Test if the specified index represents an open connection.
haveIndex( $i)
Returns true if the specified index is a valid server index.
__call( $name, $arguments)
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
getServerName( $i)
Get the host name or IP address of the server with the specified index Prefer a readable name if avai...
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
bool DBMasterPos $mWaitForPos
False if not set *.
closeConnection( $conn)
Close a connection Using this function makes sure the LoadBalancer knows the connection is closed.
getLoadMonitor()
Get a LoadMonitor instance.
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
isNonZeroLoad( $i)
Returns true if the specified index is valid and has non-zero load.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfProfileIn( $functionname)
Begin profiling of a function.
wfHostname()
Fetch server name for use in error reporting etc.
wfSplitWikiID( $wiki)
Split a wiki ID into DB name and table prefix.
safeGetLag( $conn)
Get the lag in seconds for a given connection, or zero if this load balancer does not have replicatio...
parentInfo( $x=null)
Get or set arbitrary data used by the parent object, usually an LBFactory.
sleep( $t)
Wait for a specified number of microseconds, and return the period waited.
closeAll()
Close all open connections.
An object representing a master or slave position in a replicated setup.
bool DatabaseBase $mErrorConnection
Database connection that caused a problem *.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Class for handling function-scope profiling.
reallyOpenConnection( $server, $dbNameOverride=false)
Really opens a connection.
Helper class to handle automatically marking connectons as reusable (via RAII pattern) as well handli...
waitFor( $pos)
Set the master wait position If a DB_SLAVE connection has been opened already, waits Otherwise sets a...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getRandomNonLagged( $loads, $wiki=false)
getLazyConnectionRef( $db, $groups=array(), $wiki=false)
Get a database connection handle reference without connecting yet.
commitMasterChanges()
Issue COMMIT only on master, only if queries were done on connection.
waitForAll( $pos)
Set the master wait position and wait for ALL slaves to catch up to it.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
getMaxLag( $wiki=false)
Get the hostname and lag time of the most-lagged slave.
getConnectionRef( $db, $groups=array(), $wiki=false)
Get a database connection handle reference.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
static factory( $dbType, $p=array())
Given a DB type, construct the name of the appropriate child class of DatabaseBase.
doWait( $index, $open=false)
Wait for a given slave to catch up to the master pos stored in $this.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
commitAll()
Commit transactions on all open connections.
Database load balancing object.
allowLagged( $mode=null)
Disables/enables lag checks.
getReaderIndex( $group=false, $wiki=false)
Get the index of the reader connection, which may be a slave This takes into account load ratios and ...
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Allows to change the fields on the form that will be generated $name
wfLogDBError( $text)
Log for database errors.
getMasterPos()
Get the current master position for chronology control purposes.
Database abstraction object.
getServerInfo( $i)
Return the server info structure for a given index, or false if the index is invalid.
pickRandom( $weights)
Given an array of non-normalised probabilities, this function will select an element and return the a...
Interface for classes that implement or wrap DatabaseBase.
getAnyOpenConnection( $i)
Get any open connection to a given server index, local or foreign Returns false if there is no connec...
setServerInfo( $i, $serverInfo)
Sets the server info structure for the given index.
waitTimeout( $value=null)
static pickRandom( $weights)
Given an array of non-normalised probabilities, this function will select an element and return the a...
getLagTimes( $wiki=false)
Get lag time for each server Results are cached for a short time in memcached, and indefinitely in th...
openConnection( $i, $wiki=false)
Open a connection to the server given by the specified index Index must be an actual index into the a...
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
& getConnection( $i, $groups=array(), $wiki=false)
Get a connection by index This is the main entry point for this class.
openForeignConnection( $i, $wiki)
Open a connection to a foreign DB, or return one if it is already open.
__construct(LoadBalancer $lb, $conn)
reuseConnection( $conn)
Mark a foreign connection as being available for reuse under a different DB name or prefix.
forEachOpenConnection( $callback, $params=array())
Call a function with each open connection object.
hasMasterChanges()
Determine if there are any pending changes that need to be rolled back or committed.
closeConnecton( $conn)
Deprecated function, typo in function name.
getServerCount()
Get the number of defined servers (not the number of open connections)
rollbackMasterChanges()
Issue ROLLBACK only on master, only if queries were done on connection.
clearLagTimeCache()
Clear the cache for getLagTimes.