Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/234723?usp=email )

Change subject: Disable maxlag for meta queries, paraminfo and help
......................................................................

Disable maxlag for meta queries, paraminfo and help

Paraminfo and help do not require database or disk access and are not
expected to put significant load on the server. The same applies to
many meta queries, which are served from memory or cache.

maxlag is an imperfect indicator of overall server load and is not
designed to measure the load caused by individual read operations.
Applying it to lightweight requests can therefore make bots wait for
server lag that is unrelated to the actual cost of the request.

This has become particularly problematic since May, with recurring
maxlag-related issues and maxlag rarely dropping below 5 in recent
weeks. Avoiding maxlag for these requests prevents bots from being
unnecessarily delayed by persistent server lag.

Bug: T421642
Change-Id: I737549f0c7a66917853af9690cf977b3d3090fcf
---
M pywikibot/data/api/_requests.py
1 file changed, 14 insertions(+), 3 deletions(-)

Approvals:
  Xqt: Verified; Looks good to me, approved




diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index 789ac9d..38d67da 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -420,6 +420,9 @@
         """Add default parameters to the API request.

         This method will only add them once.
+
+        .. version-changed:: 11.8
+           Disable maxlag for meta queries and paraminfo action.
         """
         if hasattr(self, '__defaulted'):
             return
@@ -429,8 +432,13 @@
             raise ValueError('The mime and params shall not share the '
                              'same keys.')

+        maxlag = config.maxlag
+
         if self.action == 'query':
             meta = self._params.get('meta', [])
+            if meta:
+                maxlag = None
+
             # Special logic for private wikis (T153903).
             # If the wiki requires login privileges to read articles, pywikibot
             # will be blocked from accessing the userinfo.
@@ -449,17 +457,20 @@
                 prop = set(self['prop'] + ['proofread'])
                 self['prop'] = sorted(prop)

+        elif self.action == 'paraminfo':
+            maxlag = None
         elif self.action == 'help':
+            maxlag = None
             self['wrap'] = ''

-        if config.maxlag:
-            self._params.setdefault('maxlag', [str(config.maxlag)])
+        if maxlag:
+            self._params.setdefault('maxlag', [str(maxlag)])
         self._params.setdefault('format', ['json'])
         if self['format'] != ['json']:
             raise TypeError(
                 f'Query format {self["format"]!r} cannot be parsed.')

-        self.__defaulted = True  # skipcq: PTC-W0037
+        self.__defaulted = True

     def _encoded_items(self) -> dict[str, str | bytes]:
         """Build a dict of params with minimal encoding needed for the site.

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/234723?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I737549f0c7a66917853af9690cf977b3d3090fcf
Gerrit-Change-Number: 234723
Gerrit-PatchSet: 6
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to