From 98c3370efc10b80057700c4908ec958125ea0fef Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Sat, 5 Dec 2009 10:33:09 +0000 Subject: [PATCH] Eliminated deadlock during parser tests on SQLite --- includes/BagOStuff.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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; } -- 2.20.1