Fixed bogus mysql error code 0 on mid-transaction disconnect
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 21 Aug 2014 16:58:03 +0000 (09:58 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 21 Aug 2014 16:58:03 +0000 (09:58 -0700)
* Now the proper error (e.g. "server has gone away") and code is shown.

Change-Id: If0255101151441c7d05141ffc7cb416ad79e6bd8

includes/db/Database.php

index 62d64eb..65ae444 100644 (file)
@@ -1130,7 +1130,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        $this->mTrxIdleCallbacks = array(); // bug 65263
                        $this->mTrxPreCommitCallbacks = array(); // bug 65263
                        wfDebug( "Connection lost, reconnecting...\n" );
-
+                       # Stash the last error values since ping() might clear them
+                       $lastError = $this->lastError();
+                       $lastErrno = $this->lastErrno();
                        if ( $this->ping() ) {
                                global $wgRequestTime;
                                wfDebug( "Reconnected\n" );
@@ -1145,6 +1147,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                                if ( $hadTrx ) {
                                        # Leave $ret as false and let an error be reported.
                                        # Callers may catch the exception and continue to use the DB.
+                                       $this->reportQueryError( $lastError, $lastErrno, $sql, $fname, $tempIgnore );
                                } else {
                                        # Should be safe to silently retry (no trx and thus no callbacks)
                                        $ret = $this->doQuery( $commentedSql );