jenkins-bot has submitted this change and it was merged.
Change subject: More logging for retryable MediaWiki exceptions ......................................................................
More logging for retryable MediaWiki exceptions
The api layer retries the request when it sees a MediaWiki exception of types DBConnectionError, DBQueryError, and ReadOnlyError, and it doesnt log the details of the request/response. For other types of MediaWiki exception, it only logs them, without a user-visible warning.
However as seen by bug 72850, even these retryable exceptions can be permanent errors caused by MediaWiki bugs. We need bug reports to mention these MediaWiki exceptions when they occur, so this change uses pywikibot.error like happens for all non-fatal HTTP errors other than 503, and log the request and response.
Also use bug 62974 as a reference for DBConnectionError, rather than two revision number references to the mediawiki code review system.
Change-Id: Ia575f87f25e38619b4a0c047b2bdb6ccc5450761 --- M pywikibot/data/api.py 1 file changed, 15 insertions(+), 11 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 167a064..a685848 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -671,20 +671,24 @@
if code.startswith(u'internal_api_error_'): class_name = code[len(u'internal_api_error_'):] - if class_name in ['DBConnectionError', # r 4984 & r 4580 - 'DBQueryError', # bug 58158 - 'ReadOnlyError' # bug 59227 - ]: + retry = class_name in ['DBConnectionError', # bug 62974 + 'DBQueryError', # bug 58158 + 'ReadOnlyError' # bug 59227 + ]
- pywikibot.log(u'MediaWiki exception %s; retrying.' - % class_name) + pywikibot.error("Detected MediaWiki API exception %s%s" + % (class_name, + "; retrying" if retry else "; raising")) + pywikibot.log(u"MediaWiki exception %s details:\n" + u" query=\n%s\n" + u" response=\n%s" + % (class_name, + pprint.pformat(self._params), + result)) + + if retry: self.wait() continue - - pywikibot.log(u"MediaWiki exception %s: query=\n%s" - % (class_name, - pprint.pformat(self._params))) - pywikibot.log(u" response=\n%s" % result)
raise APIMWException(class_name, info, **result["error"])
pywikibot-commits@lists.wikimedia.org