Revert "Made LCStoreDB try to use a separate DB connection"
authorC. Scott Ananian <cscott@cscott.net>
Sun, 3 Aug 2014 21:33:46 +0000 (17:33 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Sun, 3 Aug 2014 21:40:03 +0000 (17:40 -0400)
This commit broke `php tests/parserTests.php`.

This reverts commit 4c0871fa0ef99d0d38bcba8e09fce8ef55f791d9.

Bug: 69082
Change-Id: If0781f8f51681717a848ec359c7b8c70932ed72d

includes/cache/LocalisationCache.php
includes/objectcache/SqlBagOStuff.php

index cf87129..d3721c9 100644 (file)
@@ -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();
index 32996ac..da3eda1 100644 (file)
@@ -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 );