r86363 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86362‎ | r86363 | r86364 >
Date:23:12, 18 April 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Apply LoadBalancer related fixes

Patches by Yuvi Panda

From (bug 28583) Remove all /* private */ declarations in MediaWiki core
Modified paths:
  • /trunk/extensions/MakeDBError/MakeDBError_body.php (modified) (history)
  • /trunk/extensions/SimpleSecurity/SimpleSecurity_body.php (modified) (history)
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/includes/db/LoadBalancer.php (modified) (history)
  • /trunk/phase3/maintenance/eval.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/eval.php
@@ -45,8 +45,11 @@
4646 }
4747 if ( $d > 1 ) {
4848 $lb = wfGetLB();
49 - foreach ( $lb->mServers as $i => $server ) {
50 - $lb->mServers[$i]['flags'] |= DBO_DEBUG;
 49+ $serverCount = $lb->getServerCount();
 50+ for ( $i = 0; $i < $serverCount; $i++ ) {
 51+ $server = $lb->getServerInfo( $i );
 52+ $server['flags'] |= DBO_DEBUG;
 53+ $lb->setServerInfo( $i, $server );
5154 }
5255 }
5356 if ( $d > 2 ) {
Index: trunk/phase3/CREDITS
@@ -142,6 +142,7 @@
143143 * Tisane
144144 * Umherirrender
145145 * Ville Stadista
 146+* Yuvaraj Pandian T
146147 * Zachary Hauri
147148
148149 == Translators ==
Index: trunk/phase3/includes/db/LoadBalancer.php
@@ -13,13 +13,13 @@
1414 * @ingroup Database
1515 */
1616 class LoadBalancer {
17 - /* private */ var $mServers, $mConns, $mLoads, $mGroupLoads;
18 - /* private */ var $mErrorConnection;
19 - /* private */ var $mReadIndex, $mAllowLagged;
20 - /* private */ var $mWaitForPos, $mWaitTimeout;
21 - /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error';
22 - /* private */ var $mParentInfo, $mLagTimes;
23 - /* private */ var $mLoadMonitorClass, $mLoadMonitor;
 17+ private $mServers, $mConns, $mLoads, $mGroupLoads;
 18+ private $mErrorConnection;
 19+ private $mReadIndex, $mAllowLagged;
 20+ private $mWaitForPos, $mWaitTimeout;
 21+ private $mLaggedSlaveMode, $mLastError = 'Unknown error';
 22+ private $mParentInfo, $mLagTimes;
 23+ private $mLoadMonitorClass, $mLoadMonitor;
2424
2525 /**
2626 * @param $params Array with keys:
@@ -91,8 +91,7 @@
9292 * Given an array of non-normalised probabilities, this function will select
9393 * an element and return the appropriate key
9494 */
95 - function pickRandom( $weights )
96 - {
 95+ function pickRandom( $weights ) {
9796 if ( !is_array( $weights ) || count( $weights ) == 0 ) {
9897 return false;
9998 }
@@ -740,6 +739,13 @@
741740 }
742741
743742 /**
 743+ * Sets the server info structure for the given index. Entry at index $i is created if it doesn't exist
 744+ */
 745+ function setServerInfo( $i, $serverInfo ) {
 746+ $this->mServers[i] = $serverInfo;
 747+ }
 748+
 749+ /**
744750 * Get the current master position for chronology control purposes
745751 * @return mixed
746752 */
Index: trunk/extensions/SimpleSecurity/SimpleSecurity_body.php
@@ -378,7 +378,12 @@
379379 */
380380 static function updateLB( &$lb ) {
381381 $lb->closeAll();
382 - foreach ( $lb->mServers as $i => $server ) $lb->mServers[$i]['type'] = 'SimpleSecurity';
 382+ $serverCount = $lb->getServerCount();
 383+ for ( $i = 0; $i < $serverCount; $i++ ) {
 384+ $server = $lb->getServerInfo( $i );
 385+ $sever['type'] = 'SimpleSecurity';
 386+ $lb->setServerInfo ( $i, $server );
 387+ }
383388 }
384389
385390
Index: trunk/extensions/MakeDBError/MakeDBError_body.php
@@ -14,9 +14,10 @@
1515 $this->setHeaders();
1616 if ( $par == 'connection' ) {
1717 $lb = wfGetLB();
18 - $lb->mServers[1234] = $lb->mServers[0];
19 - $lb->mServers[1234]['user'] = 'chicken';
20 - $lb->mServers[1234]['password'] = 'cluck cluck';
 18+ $failServer = $lb->getServerInfo( 0 );
 19+ $failServer['user'] = 'chicken';
 20+ $failServer['password'] = 'cluck cluck';
 21+ $lb->setServerInfo ( 1234, $failServer ); /* What happens when there *are* actually >1234 servers? */
2122 $db = wfGetDB( 1234 );
2223 $wgOut->addHTML("<pre>" . var_export( $db, true ) . "</pre>" );
2324 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r86365Apply Extension related new constructor fixes...reedy23:17, 18 April 2011
r86367Apply phase3 related Title fixes. With one minor addition, Title constructor ...reedy23:20, 18 April 2011
r87238Follow up r86363 - Missing a dollar sign....bawolff07:42, 2 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86335(bug 28583) chase down and beat to death external calls of functions marked /...happy-melon19:03, 18 April 2011

Comments

#Comment by Bryan (talk | contribs)   14:12, 7 May 2011

You could use a negative number instead of 1234, or even a non-numeric string.

Status & tagging log