r96517 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96516‎ | r96517 | r96518 >
Date:23:21, 7 September 2011
Author:reedy
Status:ok (Comments)
Tags:tstarling 
Comment:
Merge r90266 to trunk

Fixes fixme on r75341, r75343
Modified paths:
  • /trunk/phase3/includes/db/LoadBalancer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/LoadBalancer.php
@@ -242,7 +242,8 @@
243243 if ( $i === false && count( $currentLoads ) != 0 ) {
244244 # All slaves lagged. Switch to read-only mode
245245 wfDebugLog( 'replication', "All slaves lagged. Switch to read-only mode\n" );
246 - $wgReadOnly = wfMessage( 'readonly_lag' )->useDatabase( false )->plain();
 246+ $wgReadOnly = 'The database has been automatically locked ' .
 247+ 'while the slave database servers catch up to the master';
247248 $i = $this->pickRandom( $currentLoads );
248249 $laggedSlaveMode = true;
249250 }
@@ -679,7 +680,14 @@
680681
681682 # Create object
682683 wfDebug( "Connecting to $host $dbname...\n" );
683 - $db = DatabaseBase::factory( $server['type'], $server );
 684+ try {
 685+ $db = DatabaseBase::factory( $server['type'], $server );
 686+ } catch ( DBConnectionError $e ) {
 687+ // FIXME: This is probably the ugliest thing I have ever done to
 688+ // PHP. I'm half-expecting it to segfault, just out of disgust. -- TS
 689+ $db = $e->db;
 690+ }
 691+
684692 if ( $db->isOpen() ) {
685693 wfDebug( "Connected to $host $dbname.\n" );
686694 } else {
@@ -929,7 +937,7 @@
930938 /**
931939 * Get the hostname and lag time of the most-lagged slave.
932940 * This is useful for maintenance scripts that need to throttle their updates.
933 - * May attempt to open connections to slaves on the default DB. If there is
 941+ * May attempt to open connections to slaves on the default DB. If there is
934942 * no lag, the maximum lag will be reported as -1.
935943 *
936944 * @param $wiki string Wiki ID, or false for the default database
@@ -981,19 +989,19 @@
982990 $this->mLagTimes = array( 0 => 0 );
983991 } else {
984992 # Send the request to the load monitor
985 - $this->mLagTimes = $this->getLoadMonitor()->getLagTimes(
 993+ $this->mLagTimes = $this->getLoadMonitor()->getLagTimes(
986994 array_keys( $this->mServers ), $wiki );
987995 }
988996 return $this->mLagTimes;
989997 }
990998
991999 /**
992 - * Get the lag in seconds for a given connection, or zero if this load
993 - * balancer does not have replication enabled.
 1000+ * Get the lag in seconds for a given connection, or zero if this load
 1001+ * balancer does not have replication enabled.
9941002 *
995 - * This should be used in preference to Database::getLag() in cases where
996 - * replication may not be in use, since there is no way to determine if
997 - * replication is in use at the connection level without running
 1003+ * This should be used in preference to Database::getLag() in cases where
 1004+ * replication may not be in use, since there is no way to determine if
 1005+ * replication is in use at the connection level without running
9981006 * potentially restricted queries such as SHOW SLAVE STATUS. Using this
9991007 * function instead of Database::getLag() avoids a fatal error in this
10001008 * case on many installations.

Follow-up revisions

RevisionCommit summaryAuthorDate
r96518Merge r96517/r90266 to REL1_18reedy23:25, 7 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75341Start of bug 24853, killing off 'functional' parts of failfunction code. Seem...reedy20:48, 24 October 2010
r75343(bug 24853) Kill failFunction - Fixed! :Dreedy21:27, 24 October 2010
r90266* (bug 29233) Temporary fix which roughly restores the 1.16 behaviour of open...tstarling12:59, 17 June 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:33, 8 September 2011

What does this mean for readonly_lag message?

#Comment by Reedy (talk | contribs)   09:48, 8 September 2011

Tim said on the original "Unfortunately wfMsgNoDB() doesn't do what it says anymore."

So if it does now work as expected when you do "wfMessage( 'readonly_lag' )->useDatabase( false )->plain()", we can revert that back to it's previous state

#Comment by Aaron Schulz (talk | contribs)   22:26, 2 November 2011

So can this be cleaned up now?

#Comment by Nikerabbit (talk | contribs)   09:02, 3 November 2011

So, what is the expected behavior?

#Comment by Nikerabbit (talk | contribs)   09:50, 8 September 2011

I don't know, but there shouldn't be any unused messages in MessagesEn.php

#Comment by Hashar (talk | contribs)   11:24, 5 December 2011

Marking fixme so someone can have a look at it. Looks like the revision can be reverted.

#Comment by Reedy (talk | contribs)   16:37, 5 December 2011

If you revert this revision, you'll break a lot of things

In Tims r90266 commit he said:

"* Don't go into infinite recursion when LCStore_DB is used and read-only mode is triggered. Unfortunately wfMsgNoDB() doesn't do what it says anymore."

So, we should probably just remove the message from MessagesEn.php and also messages.inc if necessary

#Comment by P858snake (talk | contribs)   06:44, 10 December 2011

So is there a FIXME issue or not?

#Comment by Hashar (talk | contribs)   09:14, 10 December 2011

Yeah there is a fixme, the loadbalancer code need to be rewritten properly to avoid this ugly hack. Tagging for Tim, will try to talk to him about that.

#Comment by Reedy (talk | contribs)   17:07, 12 December 2011

I'm not sure if marking this as fixme is the best way to fix it. Wouldn't it be better to create a bug, tag it platformeng and give it a reasonable priority?

#Comment by Hashar (talk | contribs)   17:16, 13 December 2011

I have opened bug 33036 to track the issue and tagged it with keyword platformeng :)

#Comment by Hashar (talk | contribs)   23:23, 12 December 2011

Talked with Tim about it, will open tomorrow a bug report about the FIXME comment.

Status & tagging log