From: Aaron Schulz Date: Thu, 2 Apr 2015 19:33:30 +0000 (-0700) Subject: Made rollbackMasterChanges catch exceptions, throwing the last one X-Git-Tag: 1.31.0-rc.0~11854^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=02a5f968dfbdd744c2d53bc82a4ed3c87dc5a1e2;p=lhc%2Fweb%2Fwiklou.git Made rollbackMasterChanges catch exceptions, throwing the last one Change-Id: Ida36a302b35434d1af464cb77a0084ec441d038a --- diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 48c636e484..d9584e147b 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -978,7 +978,6 @@ class LoadBalancer { * Issue COMMIT only on master, only if queries were done on connection */ public function commitMasterChanges() { - // Always 0, but who knows.. :) $masterIndex = $this->getWriterIndex(); foreach ( $this->mConns as $conns2 ) { if ( empty( $conns2[$masterIndex] ) ) { @@ -998,7 +997,8 @@ class LoadBalancer { * @since 1.23 */ public function rollbackMasterChanges() { - // Always 0, but who knows.. :) + $failedServers = array(); + $masterIndex = $this->getWriterIndex(); foreach ( $this->mConns as $conns2 ) { if ( empty( $conns2[$masterIndex] ) ) { @@ -1007,10 +1007,20 @@ class LoadBalancer { /** @var DatabaseBase $conn */ foreach ( $conns2[$masterIndex] as $conn ) { if ( $conn->trxLevel() && $conn->writesOrCallbacksPending() ) { - $conn->rollback( __METHOD__, 'flush' ); + try { + $conn->rollback( __METHOD__, 'flush' ); + } catch ( DBError $e ) { + MWExceptionHandler::logException( $e ); + $failedServers[] = $conn->getServer(); + } } } } + + if ( $failedServers ) { + throw new DBExpectedError( null, "Rollback failed on server(s) " . + implode( ', ', array_unique( $failedServers ) ) ); + } } /** @@ -1027,7 +1037,6 @@ class LoadBalancer { * @return bool */ public function hasMasterChanges() { - // Always 0, but who knows.. :) $masterIndex = $this->getWriterIndex(); foreach ( $this->mConns as $conns2 ) { if ( empty( $conns2[$masterIndex] ) ) { @@ -1050,7 +1059,6 @@ class LoadBalancer { */ public function lastMasterChangeTimestamp() { $lastTime = false; - // Always 0, but who knows.. :) $masterIndex = $this->getWriterIndex(); foreach ( $this->mConns as $conns2 ) { if ( empty( $conns2[$masterIndex] ) ) {