diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
commit | 086ae52d12011746a75f5588e877347bc0457352 (patch) | |
tree | e73263c7a29d0f94fafb874562610e16eb292ba8 /includes/LoadBalancer.php | |
parent | 749e7fb2bae7bbda855de3c9e319435b9f698ff7 (diff) |
Update auf MediaWiki 1.12.0
Diffstat (limited to 'includes/LoadBalancer.php')
-rw-r--r-- | includes/LoadBalancer.php | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php index 65a6d5a6..0cdadd1e 100644 --- a/includes/LoadBalancer.php +++ b/includes/LoadBalancer.php @@ -16,12 +16,6 @@ class LoadBalancer { /* private */ var $mWaitForFile, $mWaitForPos, $mWaitTimeout; /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error'; - /** - * Scale polling time so that under overload conditions, the database server - * receives a SHOW STATUS query at an average interval of this many microseconds - */ - const AVG_STATUS_POLL = 2000; - function __construct( $servers, $failFunction = false, $waitTimeout = 10, $waitForMasterNow = false ) { $this->mServers = $servers; @@ -133,7 +127,7 @@ class LoadBalancer { * Side effect: opens connections to databases */ function getReaderIndex() { - global $wgReadOnly, $wgDBClusterTimeout; + global $wgReadOnly, $wgDBClusterTimeout, $wgDBAvgStatusPoll; $fname = 'LoadBalancer::getReaderIndex'; wfProfileIn( $fname ); @@ -180,7 +174,7 @@ class LoadBalancer { # Too much load, back off and wait for a while. # The sleep time is scaled by the number of threads connected, # to produce a roughly constant global poll rate. - $sleepTime = self::AVG_STATUS_POLL * $status['Threads_connected']; + $sleepTime = $wgDBAvgStatusPoll * $status['Threads_connected']; # If we reach the timeout and exit the loop, don't use it $i = false; @@ -324,13 +318,13 @@ class LoadBalancer { # Query groups if ( !is_array( $groups ) ) { - $groupIndex = $this->getGroupIndex( $groups, $i ); + $groupIndex = $this->getGroupIndex( $groups ); if ( $groupIndex !== false ) { $i = $groupIndex; } } else { foreach ( $groups as $group ) { - $groupIndex = $this->getGroupIndex( $group, $i ); + $groupIndex = $this->getGroupIndex( $group ); if ( $groupIndex !== false ) { $i = $groupIndex; break; @@ -432,8 +426,7 @@ class LoadBalancer { return $db; } - function reportConnectionError( &$conn ) - { + function reportConnectionError( &$conn ) { $fname = 'LoadBalancer::reportConnectionError'; wfProfileIn( $fname ); # Prevent infinite recursion @@ -552,6 +545,17 @@ class LoadBalancer { } } } + + /* Issue COMMIT only on master, only if queries were done on connection */ + function commitMasterChanges() { + // Always 0, but who knows.. :) + $i = $this->getWriterIndex(); + if (array_key_exists($i,$this->mConnections)) { + if ($this->mConnections[$i]->lastQuery() != '') { + $this->mConnections[$i]->immediateCommit(); + } + } + } function waitTimeout( $value = NULL ) { return wfSetVar( $this->mWaitTimeout, $value ); |