From: Max Semenik Date: Sat, 5 Dec 2009 10:33:09 +0000 (+0000) Subject: Eliminated deadlock during parser tests on SQLite X-Git-Tag: 1.31.0-rc.0~38619 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=98c3370efc10b80057700c4908ec958125ea0fef;p=lhc%2Fweb%2Fwiklou.git Eliminated deadlock during parser tests on SQLite --- diff --git a/includes/BagOStuff.php b/includes/BagOStuff.php index 327bc5ad98..c4dd4aadd0 100644 --- a/includes/BagOStuff.php +++ b/includes/BagOStuff.php @@ -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; }