Eliminated deadlock during parser tests on SQLite
authorMax Semenik <maxsem@users.mediawiki.org>
Sat, 5 Dec 2009 10:33:09 +0000 (10:33 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Sat, 5 Dec 2009 10:33:09 +0000 (10:33 +0000)
includes/BagOStuff.php

index 327bc5a..c4dd4aa 100644 (file)
@@ -221,10 +221,19 @@ class SqlBagOStuff extends BagOStuff {
        var $lastExpireAll = 0;
 
        protected function getDB() {
-               if ( !isset( $this->lb ) ) {
-                       $this->lb = wfGetLBFactory()->newMainLB();
-                       $this->db = $this->lb->getConnection( DB_MASTER );
-                       $this->db->clearFlag( DBO_TRX );
+               global $wgDBtype;
+               if ( !isset( $this->db ) ) {
+                       /* We must keep a separate connection to MySQL in order to avoid deadlocks
+                        * However, SQLite has an opposite behaviour.
+                        * @todo Investigate behaviour for other databases
+                        */
+                       if ( $wgDBtype == 'sqlite' ) {
+                               $this->db = wfGetDB( DB_MASTER );
+                       } else {
+                               $this->lb = wfGetLBFactory()->newMainLB();
+                               $this->db = $this->lb->getConnection( DB_MASTER );
+                               $this->db->clearFlag( DBO_TRX );
+                       }
                }
                return $this->db;
        }