From 9c0fff5a4b4e0963df4c163b702169fafd4a34b0 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Sun, 3 Aug 2014 17:33:46 -0400 Subject: [PATCH] Revert "Made LCStoreDB try to use a separate DB connection" This commit broke `php tests/parserTests.php`. This reverts commit 4c0871fa0ef99d0d38bcba8e09fce8ef55f791d9. Bug: 69082 Change-Id: If0781f8f51681717a848ec359c7b8c70932ed72d --- includes/cache/LocalisationCache.php | 15 +++------------ includes/objectcache/SqlBagOStuff.php | 15 ++++++++++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/includes/cache/LocalisationCache.php b/includes/cache/LocalisationCache.php index cf87129732..d3721c9e65 100644 --- a/includes/cache/LocalisationCache.php +++ b/includes/cache/LocalisationCache.php @@ -1163,8 +1163,8 @@ class LCStoreDB implements LCStore { private $readOnly = false; public function get( $code, $key ) { - if ( $this->writesDone && $this->dbw ) { - $db = $this->dbw; + if ( $this->writesDone ) { + $db = wfGetDB( DB_MASTER ); } else { $db = wfGetDB( DB_SLAVE ); } @@ -1184,16 +1184,7 @@ class LCStoreDB implements LCStore { throw new MWException( __METHOD__ . ": Invalid language \"$code\"" ); } - // We must keep a separate connection to MySQL in order to avoid breaking - // main transactions. However, SQLite deadlocks when using two connections. - // @todo get this trick to work on PostgreSQL too - if ( wfGetDB( DB_MASTER )->getType() == 'mysql' ) { - $lb = wfGetLBFactory()->newMainLB(); - $this->dbw = $lb->getConnection( DB_MASTER ); - $this->dbw->clearFlag( DBO_TRX ); // auto-commit mode - } else { - $this->dbw = wfGetDB( DB_MASTER ); - } + $this->dbw = wfGetDB( DB_MASTER ); $this->currentLang = $code; $this->batch = array(); diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 32996acfeb..da3eda1635 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -27,6 +27,9 @@ * @ingroup Cache */ class SqlBagOStuff extends BagOStuff { + /** @var LoadBalancer */ + protected $lb; + protected $serverInfos; /** @var array */ @@ -143,12 +146,14 @@ class SqlBagOStuff extends BagOStuff { $db = DatabaseBase::factory( $type, $info ); $db->clearFlag( DBO_TRX ); } else { - // We must keep a separate connection to MySQL in order to avoid deadlocks - // However, SQLite has an opposite behavior. - // @todo get this trick to work on PostgreSQL too + /* + * We must keep a separate connection to MySQL in order to avoid deadlocks + * However, SQLite has an opposite behavior. And PostgreSQL needs to know + * if we are in transaction or no + */ if ( wfGetDB( DB_MASTER )->getType() == 'mysql' ) { - $lb = wfGetLBFactory()->newMainLB(); - $db = $lb->getConnection( DB_MASTER ); + $this->lb = wfGetLBFactory()->newMainLB(); + $db = $this->lb->getConnection( DB_MASTER ); $db->clearFlag( DBO_TRX ); // auto-commit mode } else { $db = wfGetDB( DB_MASTER ); -- 2.20.1