From: Tim Starling Date: Fri, 29 Aug 2008 08:35:00 +0000 (+0000) Subject: * Fixed intermittent deadlock errors involving objectcache table queries. Use a separ... X-Git-Tag: 1.31.0-rc.0~45572 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=5c42b437f3a1454b9b79c679111854138c47e14d;p=lhc%2Fweb%2Fwiklou.git * Fixed intermittent deadlock errors involving objectcache table queries. Use a separate database connection for the objectcache table to avoid long-lasting locks on that table. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d12e7dff85..6e7b0f69e2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -158,6 +158,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 15172) 'Go' button of Special:Recentchanges now on the same line as the last input element (like Special:Watchlist too) * (bug 15351) Fix fatal error for invalid section fragments in autocomments +* Fixed intermittent deadlock errors involving objectcache table queries. + Use a separate database connection for the objectcache table to avoid + long-lasting locks on that table. === API changes in 1.14 === diff --git a/includes/BagOStuff.php b/includes/BagOStuff.php index b4fefc97aa..9231132991 100644 --- a/includes/BagOStuff.php +++ b/includes/BagOStuff.php @@ -271,12 +271,15 @@ abstract class SqlBagOStuff extends BagOStuff { $exptime += time(); $exp = $this->_fromunixtime($exptime); } - $this->delete( $key ); + $this->_begin(); + $this->_query( + "DELETE FROM $0 WHERE keyname='$1'", $key ); $this->_doinsert($this->getTableName(), array( 'keyname' => $key, 'value' => $this->_blobencode($this->_serialize($value)), 'exptime' => $exp )); + $this->_commit(); return true; /* ? */ } @@ -284,8 +287,10 @@ abstract class SqlBagOStuff extends BagOStuff { if ( $this->_readonly() ) { return false; } + $this->_begin(); $this->_query( "DELETE FROM $0 WHERE keyname='$1'", $key ); + $this->_commit(); return true; /* ? */ } @@ -339,6 +344,9 @@ abstract class SqlBagOStuff extends BagOStuff { abstract function _readonly(); + function _begin() {} + function _commit() {} + function _freeresult($result) { /* stub */ return false; @@ -370,7 +378,9 @@ abstract class SqlBagOStuff extends BagOStuff { return false; } $now = $this->_fromunixtime( time() ); + $this->_begin(); $this->_query( "DELETE FROM $0 WHERE exptime < '$now'" ); + $this->_commit(); } function deleteall() { @@ -378,7 +388,9 @@ abstract class SqlBagOStuff extends BagOStuff { if ( $this->_readonly() ) { return false; } + $this->_begin(); $this->_query( "DELETE FROM $0" ); + $this->_commit(); } /** @@ -422,12 +434,21 @@ abstract class SqlBagOStuff extends BagOStuff { */ class MediaWikiBagOStuff extends SqlBagOStuff { var $tableInitialised = false; + var $lb, $db; function _getDB(){ - static $db; - if( !isset( $db ) ) - $db = wfGetDB( DB_MASTER ); - return $db; + if ( !isset( $this->lb ) ) { + $this->lb = wfGetLBFactory()->newMainLB(); + $this->db = $this->lb->getConnection( DB_MASTER ); + $this->db->clearFlag( DBO_TRX ); + } + return $this->db; + } + function _begin() { + $this->_getDB()->begin(); + } + function _commit() { + $this->_getDB()->commit(); } function _doquery($sql) { return $this->_getDB()->query( $sql, __METHOD__ );