* Fixed intermittent deadlock errors involving objectcache table queries. Use a separ...
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 29 Aug 2008 08:35:00 +0000 (08:35 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 29 Aug 2008 08:35:00 +0000 (08:35 +0000)
RELEASE-NOTES
includes/BagOStuff.php

index d12e7df..6e7b0f6 100644 (file)
@@ -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 ===
index b4fefc9..9231132 100644 (file)
@@ -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__ );