r75341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75340‎ | r75341 | r75342 >
Date:20:48, 24 October 2010
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Start of bug 24853, killing off 'functional' parts of failfunction code. Seems when the constructors start getting changed, it starts borking. Using this as a point of reversion/stashing
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMssql.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)
  • /trunk/phase3/includes/db/LoadBalancer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -103,7 +103,6 @@
104104 function __construct( $server = false, $user = false, $password = false, $dbName = false,
105105 $failFunction = false, $flags = 0 )
106106 {
107 - $this->mFailFunction = $failFunction;
108107 $this->mFlags = $flags;
109108 $this->open( $server, $user, $password, $dbName );
110109 }
@@ -192,11 +191,7 @@
193192 wfDebug( "DB connection error\n" );
194193 wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" );
195194 wfDebug( $this->lastError() . "\n" );
196 - if ( !$this->mFailFunction ) {
197 - throw new DBConnectionError( $this, $phpError );
198 - } else {
199 - return false;
200 - }
 195+ throw new DBConnectionError( $this, $phpError );
201196 }
202197
203198 $this->mOpened = true;
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php
@@ -273,7 +273,6 @@
274274 $wgOut = null;
275275 }
276276 $this->mOut =& $wgOut;
277 - $this->mFailFunction = $failFunction;
278277 $this->mFlags = DBO_TRX | $flags;
279278
280279 if ( $schema == self::USE_GLOBAL ) {
Index: trunk/phase3/includes/db/Database.php
@@ -236,14 +236,6 @@
237237 }
238238
239239 /**
240 - * Fail function, takes a Database as a parameter
241 - * Set to false for default, 1 for ignore errors
242 - */
243 - function failFunction( $function = null ) {
244 - return wfSetVar( $this->mFailFunction, $function );
245 - }
246 -
247 - /**
248240 * Boolean, controls output of large amounts of debug information
249241 */
250242 function debug( $debug = null ) {
@@ -500,8 +492,6 @@
501493 if ( !isset( $wgOut ) ) {
502494 $wgOut = null;
503495 }
504 -
505 - $this->mFailFunction = $failFunction;
506496 $this->mFlags = $flags;
507497
508498 if ( $this->mFlags & DBO_DEFAULT ) {
@@ -589,16 +579,8 @@
590580 $error = $myError;
591581 }
592582
593 - if ( $this->mFailFunction ) {
594 - # Legacy error handling method
595 - if ( !is_int( $this->mFailFunction ) ) {
596 - $ff = $this->mFailFunction;
597 - $ff( $this, $error );
598 - }
599 - } else {
600 - # New method
601 - throw new DBConnectionError( $this, $error );
602 - }
 583+ # New method
 584+ throw new DBConnectionError( $this, $error );
603585 }
604586
605587 /**
Index: trunk/phase3/includes/db/DatabaseMssql.php
@@ -20,10 +20,8 @@
2121 function __construct( $server = false, $user = false, $password = false, $dbName = false,
2222 $failFunction = false, $flags = 0 )
2323 {
24 - $this->mFailFunction = $failFunction;
2524 $this->mFlags = $flags;
2625 $this->open( $server, $user, $password, $dbName );
27 -
2826 }
2927
3028 function cascadingDeletes() {
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -25,7 +25,6 @@
2626 */
2727 function __construct( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0 ) {
2828 global $wgSharedDB;
29 - $this->mFailFunction = $failFunction;
3029 $this->mFlags = $flags;
3130 $this->mName = $dbName;
3231
@@ -80,12 +79,7 @@
8180 }
8281 if ( !$this->mConn ) {
8382 wfDebug( "DB connection error: $err\n" );
84 - if ( !$this->mFailFunction ) {
85 - throw new DBConnectionError( $this, $err );
86 - } else {
87 - return false;
88 - }
89 -
 83+ throw new DBConnectionError( $this, $err );
9084 }
9185 $this->mOpened = !!$this->mConn;
9286 # set error codes only, don't raise exceptions
Index: trunk/phase3/includes/db/LoadBalancer.php
@@ -35,11 +35,6 @@
3636 }
3737 $this->mServers = $params['servers'];
3838
39 - if ( isset( $params['failFunction'] ) ) {
40 - $this->mFailFunction = $params['failFunction'];
41 - } else {
42 - $this->mFailFunction = false;
43 - }
4439 if ( isset( $params['waitTimeout'] ) ) {
4540 $this->mWaitTimeout = $params['waitTimeout'];
4641 } else {
@@ -671,19 +666,9 @@
672667 // No last connection, probably due to all servers being too busy
673668 wfLogDBError( "LB failure with no last connection\n" );
674669 $conn = new Database;
675 - if ( $this->mFailFunction ) {
676 - $conn->failFunction( $this->mFailFunction );
677 - $conn->reportConnectionError( $this->mLastError );
678 - } else {
679 - // If all servers were busy, mLastError will contain something sensible
680 - throw new DBConnectionError( $conn, $this->mLastError );
681 - }
 670+ // If all servers were busy, mLastError will contain something sensible
 671+ throw new DBConnectionError( $conn, $this->mLastError );
682672 } else {
683 - if ( $this->mFailFunction ) {
684 - $conn->failFunction( $this->mFailFunction );
685 - } else {
686 - $conn->failFunction( false );
687 - }
688673 $server = $conn->getProperty( 'mServer' );
689674 wfLogDBError( "Connection error: {$this->mLastError} ({$server})\n" );
690675 $conn->reportConnectionError( "{$this->mLastError} ({$server})" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r75343(bug 24853) Kill failFunction - Fixed! :Dreedy21:27, 24 October 2010
r75444Followup r75431, bug 24853. Add to RELEASE-NOTESreedy17:12, 26 October 2010
r90266* (bug 29233) Temporary fix which roughly restores the 1.16 behaviour of open...tstarling12:59, 17 June 2011
r96517Merge r90266 to trunk...reedy23:21, 7 September 2011

Comments

#Comment by Tim Starling (talk | contribs)   10:31, 17 June 2011

Fixme as per CR r75343.

#Comment by Reedy (talk | contribs)   10:43, 17 June 2011

bug 29233

What exactly is needed to be done to fix this...?

It seems there isn't much of the code that obviously does something, so it's something subtle. There is the removal of the "reportConnectionError" call, which only just did the throwing of a new DBConnectionError, just from a different place, so the same behaviour occurs...

The $conn->failFunction calls were essentially no-ops, just propagating the value of mFailFunction from the load balancer stuff, out to the connection, which was defaulted to false.

There is the one setting of failFunction to 1 in the LoadBalancer Constructor

#Comment by Aaron Schulz (talk | contribs)   00:51, 21 July 2011
-		if ( $this->mFailFunction ) {
-			# Legacy error handling method
-			if ( !is_int( $this->mFailFunction ) ) {
-				$ff = $this->mFailFunction;
-				$ff( $this, $error );
-			}
-		} else {
-			# New method
-			throw new DBConnectionError( $this, $error );
-		}

I guess the places where $this->mFailFunction was set to 1 needed this.

#Comment by Bryan (talk | contribs)   17:33, 30 June 2011

Can't we just revert this? It doesn't hurt to have failFunction around, and killing it appears to give more trouble than it's worth.

#Comment by 😂 (talk | contribs)   17:35, 30 June 2011

Well it's completely useless and clutters the DB constructors. What problems still exist as of HEAD?

#Comment by Reedy (talk | contribs)   17:52, 30 June 2011

It's been removed in the released 1.17 from the start

Per the CR on this and r75343, it causes some failover issues with slave DB servers

#Comment by Brion VIBBER (talk | contribs)   23:39, 20 July 2011

Is there anything in this revision that still needs to be fixed, or does the r90266 solution just need to be improved?

#Comment by 😂 (talk | contribs)   23:55, 7 September 2011

Per the comment I left on [[Special:Code/MediaWiki/75343#c22132|r75343]], marking RESOLVED.

#Comment by 😂 (talk | contribs)   23:55, 7 September 2011

/me stabs Code Review for the nth time

Status & tagging log