jenkins-bot has submitted this change and it was merged.

Change subject: Revert "Enforce stricter slave lag limits for bot API requests"
......................................................................


Revert "Enforce stricter slave lag limits for bot API requests"

This broke most Wikidata API PHPUnit tests.

This reverts commit dc10216e77b06b0fc7bb5e0824eb0967129c2e1f.

Change-Id: I19285ff0eddffb38cdbf45bbd05ba2d8a1816b41
---
M RELEASE-NOTES-1.27
M includes/DefaultSettings.php
M includes/api/ApiMain.php
M includes/db/loadbalancer/LoadBalancer.php
4 files changed, 6 insertions(+), 48 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index f3f0704..f8293b9 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -63,8 +63,6 @@
   setting in the relevant section of $wgLBFactoryConf.
 * User::newSystemUser() may be used to simplify the creation of passwordless
   "system" users for logged actions from scripts and extensions.
-* $wgAPIMaxLagThreshold was added to limit bot changes when databases lag
-  becomes too high.
 
 ==== External libraries ====
 
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 310b241..04f3f31 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -7324,13 +7324,6 @@
 $wgAPIMaxUncachedDiffs = 1;
 
 /**
- * Maximum amount of DB lag on a majority of DB slaves to tolerate
- * before forcing bots to retry any write requests via API errors.
- * This should be lower than the 'max lag' value in $wgLBFactoryConf.
- */
-$wgAPIMaxLagThreshold = 7;
-
-/**
  * Log file or URL (TCP or UDP) to log API requests to, or false to disable
  * API request logging
  */
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index f60f5df..c641c95 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1002,6 +1002,7 @@
         */
        protected function checkMaxLag( $module, $params ) {
                if ( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) 
) {
+                       // Check for maxlag
                        $maxLag = $params['maxlag'];
                        list( $host, $lag ) = wfGetLB()->getMaxLag();
                        if ( $lag > $maxLag ) {
@@ -1147,7 +1148,6 @@
                ) {
                        $this->dieUsageMsg( 'readrequired' );
                }
-
                if ( $module->isWriteMode() ) {
                        if ( !$this->mEnableWrite ) {
                                $this->dieUsageMsg( 'writedisabled' );
@@ -1155,46 +1155,15 @@
                        if ( !$user->isAllowed( 'writeapi' ) ) {
                                $this->dieUsageMsg( 'writerequired' );
                        }
-                       $this->checkReadOnly( $module );
+                       if ( wfReadOnly() ) {
+                               $this->dieReadOnly();
+                       }
                }
 
                // Allow extensions to stop execution for arbitrary reasons.
                $message = false;
                if ( !Hooks::run( 'ApiCheckCanExecute', array( $module, $user, 
&$message ) ) ) {
                        $this->dieUsageMsg( $message );
-               }
-       }
-
-       /**
-        * Check if the DB is read-only for this user
-        * @param ApiBase $module An Api module
-        */
-       protected function checkReadOnly( $module ) {
-               if ( wfReadOnly() ) {
-                       $this->dieReadOnly();
-               }
-
-               if ( $module->isWriteMode() && $this->getUser()->isAllowed( 
'bot' ) ) {
-                       // Figure out how many servers have passed the lag 
threshold
-                       $numLagged = 0;
-                       $lagLimit = $this->getConfig()->get( 
'APIMaxLagThreshold' );
-                       foreach ( wfGetLB()->getLagTimes() as $lag ) {
-                               if ( $lag > $lagLimit ) {
-                                       ++$numLagged;
-                               }
-                       }
-                       // If a majority of slaves are too lagged then disallow 
writes
-                       $slaveCount = wfGetLB()->getServerCount() - 1;
-                       if ( $numLagged >= ceil( $slaveCount / 2 ) ) {
-                               $parsed = $this->parseMsg( array( 
'readonlytext' ) );
-                               $this->dieUsage(
-                                       $parsed['info'],
-                                       $parsed['code'],
-                                       /* http error */
-                                       0,
-                                       array( 'readonlyreason' => "Waiting for 
$numLagged lagged database(s)" )
-                               );
-                       }
                }
        }
 
diff --git a/includes/db/loadbalancer/LoadBalancer.php 
b/includes/db/loadbalancer/LoadBalancer.php
index a5a5c37..bc9465b 100644
--- a/includes/db/loadbalancer/LoadBalancer.php
+++ b/includes/db/loadbalancer/LoadBalancer.php
@@ -68,9 +68,7 @@
        /** @var integer Warn when this many connection are held */
        const CONN_HELD_WARN_THRESHOLD = 10;
        /** @var integer Default 'max lag' when unspecified */
-       const MAX_LAG = 10;
-       /** @var integer Max time to wait for a slave to catch up (e.g. 
ChronologyProtector) */
-       const POS_WAIT_TIMEOUT = 10;
+       const MAX_LAG = 30;
 
        /**
         * @param array $params Array with keys:
@@ -84,7 +82,7 @@
                        throw new MWException( __CLASS__ . ': missing servers 
parameter' );
                }
                $this->mServers = $params['servers'];
-               $this->mWaitTimeout = self::POS_WAIT_TIMEOUT;
+               $this->mWaitTimeout = 10;
 
                $this->mReadIndex = -1;
                $this->mWriteIndex = -1;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I19285ff0eddffb38cdbf45bbd05ba2d8a1816b41
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to