Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/252877

Change subject: Add LBFactory::disableChronologyProtection method
......................................................................

Add LBFactory::disableChronologyProtection method

This is useful for things like job running entry points by avoiding
pointless overhead.

Change-Id: I007273dd95e6a2e9d258d475d383bc869d63f7b1
---
M includes/db/loadbalancer/LBFactory.php
M includes/db/loadbalancer/LBFactoryMulti.php
M includes/db/loadbalancer/LBFactorySimple.php
3 files changed, 16 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/77/252877/1

diff --git a/includes/db/loadbalancer/LBFactory.php 
b/includes/db/loadbalancer/LBFactory.php
index 8d298e0..eeeca62 100644
--- a/includes/db/loadbalancer/LBFactory.php
+++ b/includes/db/loadbalancer/LBFactory.php
@@ -26,6 +26,9 @@
  * @ingroup Database
  */
 abstract class LBFactory {
+       /** @var ChronologyProtector */
+       protected $chronProt;
+
        /** @var LBFactory */
        private static $instance;
 
@@ -42,6 +45,8 @@
                if ( isset( $conf['readOnlyReason'] ) && is_string( 
$conf['readOnlyReason'] ) ) {
                        $this->readOnlyReason = $conf['readOnlyReason'];
                }
+
+               $this->chronProt = $this->newChronologyProtector();
        }
 
        /**
@@ -259,6 +264,17 @@
        }
 
        /**
+        * Disable the ChronologyProtector for all load balancers
+        *
+        * This can be called at the start of special API entry points
+        *
+        * @since 1.27
+        */
+       public function disableChronologyProtection() {
+               $this->chronProt->setEnabled( false );
+       }
+
+       /**
         * @return ChronologyProtector
         */
        protected function newChronologyProtector() {
diff --git a/includes/db/loadbalancer/LBFactoryMulti.php 
b/includes/db/loadbalancer/LBFactoryMulti.php
index 556fd30..e58aead 100644
--- a/includes/db/loadbalancer/LBFactoryMulti.php
+++ b/includes/db/loadbalancer/LBFactoryMulti.php
@@ -76,9 +76,6 @@
  * @ingroup Database
  */
 class LBFactoryMulti extends LBFactory {
-       /** @var ChronologyProtector */
-       private $chronProt;
-
        /** @var array A map of database names to section names */
        private $sectionsByDB;
 
@@ -180,8 +177,6 @@
                                $this->$key = $conf[$key];
                        }
                }
-
-               $this->chronProt = $this->newChronologyProtector();
        }
 
        /**
diff --git a/includes/db/loadbalancer/LBFactorySimple.php 
b/includes/db/loadbalancer/LBFactorySimple.php
index b9c6cd1..1c9e094 100644
--- a/includes/db/loadbalancer/LBFactorySimple.php
+++ b/includes/db/loadbalancer/LBFactorySimple.php
@@ -29,8 +29,6 @@
        private $mainLB;
        /** @var LoadBalancer[] */
        private $extLBs = array();
-       /** @var ChronologyProtector */
-       private $chronProt;
 
        /** @var string */
        private $loadMonitorClass;
@@ -41,8 +39,6 @@
                $this->loadMonitorClass = isset( $conf['loadMonitorClass'] )
                        ? $conf['loadMonitorClass']
                        : null;
-
-               $this->chronProt = $this->newChronologyProtector();
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/252877
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I007273dd95e6a2e9d258d475d383bc869d63f7b1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to