Page MenuHomePhabricator

LinkBatch::addResultToCache: encountered invalid title
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error message
PHP Warning: LinkBatch::addResultToCache: encountered invalid title: 2- [Called from LinkBatch::addResultToCache in /srv/mediawiki/php-1.36.0-wmf.27/includes/cache/LinkBatch.php at line 238]
Stack Trace
from /srv/mediawiki/php-1.36.0-wmf.27/includes/debug/MWDebug.php(499)
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.36.0-wmf.27/includes/debug/MWDebug.php(499): trigger_error(string, integer)
#2 /srv/mediawiki/php-1.36.0-wmf.27/includes/debug/MWDebug.php(196): MWDebug::sendMessage(string, string, integer)
#3 /srv/mediawiki/php-1.36.0-wmf.27/includes/GlobalFunctions.php(1094): MWDebug::warning(string, integer, integer, string)
#4 /srv/mediawiki/php-1.36.0-wmf.27/includes/cache/LinkBatch.php(238): wfLogWarning(string)
#5 /srv/mediawiki/php-1.36.0-wmf.27/includes/cache/LinkBatch.php(191): LinkBatch->addResultToCache(LinkCache, Wikimedia\Rdbms\ResultWrapper)
#6 /srv/mediawiki/php-1.36.0-wmf.27/includes/cache/LinkBatch.php(178): LinkBatch->executeInto(LinkCache)
#7 /srv/mediawiki/php-1.36.0-wmf.27/includes/specials/pagers/MergeHistoryPager.php(109): LinkBatch->execute()
#8 /srv/mediawiki/php-1.36.0-wmf.27/includes/pager/IndexPager.php(599): MergeHistoryPager->getStartBody()
#9 /srv/mediawiki/php-1.36.0-wmf.27/includes/specials/SpecialMergeHistory.php(291): IndexPager->getBody()
#10 /srv/mediawiki/php-1.36.0-wmf.27/includes/specials/SpecialMergeHistory.php(187): SpecialMergeHistory->showHistory()
#11 /srv/mediawiki/php-1.36.0-wmf.27/includes/specialpage/SpecialPage.php(645): SpecialMergeHistory->execute(NULL)
#12 /srv/mediawiki/php-1.36.0-wmf.27/includes/specialpage/SpecialPageFactory.php(1405): SpecialPage->run(NULL)
#13 /srv/mediawiki/php-1.36.0-wmf.27/includes/MediaWiki.php(310): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#14 /srv/mediawiki/php-1.36.0-wmf.27/includes/MediaWiki.php(944): MediaWiki->performRequest()
#15 /srv/mediawiki/php-1.36.0-wmf.27/includes/MediaWiki.php(548): MediaWiki->main()
#16 /srv/mediawiki/php-1.36.0-wmf.27/index.php(53): MediaWiki->run()
#17 /srv/mediawiki/php-1.36.0-wmf.27/index.php(46): wfIndexMain()
#18 /srv/mediawiki/w/index.php(3): require(string)
#19 {main}
Impact

So far 4 of these since rolling 1.36.0-wmf.27 (T271341) to all wikis. All from itwiki.

Notes

Not yet rolling back train, will monitor.

Unsure who to tag here, no maintainers listed for merge history. Tentatively adding Platform Engineering.

Details

Request ID
YAniZgpAICEAAHjHRo8AAABJ
Request URL
https://it.wikipedia.org/w/index.php?title=Speciale%3AUnisciCronologia&submitted=1&mergepoint=&target=Teriaca&dest=Utente%3ALudovicamele%2FSandbox

Event Timeline

Umherirrender added a subscriber: Umherirrender.

Before https://gerrit.wikimedia.org/r/c/mediawiki/core/+/618636 the empty or null user name does not makes problems, because a null was passed to LinkBatch::addObj and results in a wfDebug call.

Now the invalid title is showing up, because wfLogWarning is called.

The null user name happen for anons in the history. The code has to use rev_user_text instead, which is always filled

Change 657847 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Use always filled rev_user_text on Special:MergeHistory

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

Change 657847 merged by jenkins-bot:
[mediawiki/core@master] Use always filled rev_user_text on Special:MergeHistory

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

AMooney triaged this task as Medium priority.Jan 26 2021, 9:20 PM
AMooney moved this task from Inbox to Later on the Platform Team Workboards (Clinic Duty Team) board.
Krinkle added subscribers: daniel, Krinkle.

This is an active and recently reported production error. If it is resolved, please confirm so in Logstash or by evaluating the code change relative to the error report and closing if it seems resolved. @daniel might be able to help with this area of code.

I suspect that this is caused by an empty (or otherwise invalid) user name in the revision history somewhere. I wrote a fix for a similar issue last week, see T232451: ParameterAssertionException: "Bad value for parameter $title: invalid name" (affects actions info, history, diff).

The code that logs the issue is behaving correctly, reporting data corruption. The only thing we can do here is fix the data. Perhaps we could have a script that finds some invalid user name (like the empty string) in the actor table, and replaces and references to that actor with the "Unknown user" actor. Such a script could optionally also take a known actor ID. The relevant entry in the actor table should probably be deleted once all references have been removed. Or the name could be replaced by something valid, like "Unknown User 8743".

I suspect that this is caused by an empty (or otherwise invalid) user name in the revision history somewhere. I wrote a fix for a similar issue last week, see T232451: ParameterAssertionException: "Bad value for parameter $title: invalid name" (affects actions info, history, diff).

The code that logs the issue is behaving correctly, reporting data corruption. The only thing we can do here is fix the data. Perhaps we could have a script that finds some invalid user name (like the empty string) in the actor table, and replaces and references to that actor with the "Unknown user" actor. Such a script could optionally also take a known actor ID. The relevant entry in the actor table should probably be deleted once all references have been removed. Or the name could be replaced by something valid, like "Unknown User 8743".

No, it was using a null value from a join while the name of the ip also in the result set. But the problem from the linked bug can also happen on Special:MergeHistory with invalid names in the user table. But the root cause was a null, not the empty string.

The patch set is already merged, but I have not closed the ticked to allow tracking if backporting was needed or not. But new train should be out there and logstash hopefully clean about this error

I see a new one of these that looks similar but is coming from Special:CheckUserLog instead

Stacktrace:

from /srv/mediawiki/php-1.36.0-wmf.31/includes/debug/MWDebug.php(499)
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.36.0-wmf.31/includes/debug/MWDebug.php(499): trigger_error(string, integer)
#2 /srv/mediawiki/php-1.36.0-wmf.31/includes/debug/MWDebug.php(196): MWDebug::sendMessage(string, string, integer)
#3 /srv/mediawiki/php-1.36.0-wmf.31/includes/GlobalFunctions.php(1095): MWDebug::warning(string, integer, integer, string)
#4 /srv/mediawiki/php-1.36.0-wmf.31/includes/cache/LinkBatch.php(238): wfLogWarning(string)
#5 /srv/mediawiki/php-1.36.0-wmf.31/includes/cache/LinkBatch.php(191): LinkBatch->addResultToCache(LinkCache, Wikimedia\Rdbms\ResultWrapper)
#6 /srv/mediawiki/php-1.36.0-wmf.31/includes/cache/LinkBatch.php(178): LinkBatch->executeInto(LinkCache)
#7 /srv/mediawiki/php-1.36.0-wmf.31/extensions/CheckUser/src/LogPager.php(131): LinkBatch->execute()
#8 /srv/mediawiki/php-1.36.0-wmf.31/includes/pager/IndexPager.php(286): MediaWiki\CheckUser\LogPager->preprocessResults(Wikimedia\Rdbms\ResultWrapper)
#9 /srv/mediawiki/php-1.36.0-wmf.31/includes/pager/IndexPager.php(788): IndexPager->doQuery()
#10 /srv/mediawiki/php-1.36.0-wmf.31/includes/pager/ReverseChronologicalPager.php(44): IndexPager->isNavigationBarShown()
#11 /srv/mediawiki/php-1.36.0-wmf.31/extensions/CheckUser/src/Specials/SpecialCheckUserLog.php(92): ReverseChronologicalPager->getNavigationBar()
#12 /srv/mediawiki/php-1.36.0-wmf.31/includes/specialpage/SpecialPage.php(645): MediaWiki\CheckUser\Specials\SpecialCheckUserLog->execute(NULL)
#13 /srv/mediawiki/php-1.36.0-wmf.31/includes/specialpage/SpecialPageFactory.php(1405): SpecialPage->run(NULL)
#14 /srv/mediawiki/php-1.36.0-wmf.31/includes/MediaWiki.php(310): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#15 /srv/mediawiki/php-1.36.0-wmf.31/includes/MediaWiki.php(944): MediaWiki->performRequest()
#16 /srv/mediawiki/php-1.36.0-wmf.31/includes/MediaWiki.php(548): MediaWiki->main()
#17 /srv/mediawiki/php-1.36.0-wmf.31/index.php(53): MediaWiki->run()
#18 /srv/mediawiki/php-1.36.0-wmf.31/index.php(46): wfIndexMain()
#19 /srv/mediawiki/w/index.php(3): require(string)
#20 {main}

ReqId: YDakjklPOq9GfgSok0HleAAAAEg

Seems also exclusive to loginwiki

The code to fill the LinkBatch is in SpecialMergeHistory and it is in SpecialCheckUserLog, that means it is another issue. Only the part which trigger the error is the same, because both using the same class to fill the cache.

Would suggest to have an own task to also have correct tags

Maybe it is related to T275669, but that depends on the value after encountered invalid title: in the log message, which is not provided here in the stacktrace, but from the code it could be the same database field.

Maybe it is related to T275669, but that depends on the value after encountered invalid title: in the log message, which is not provided here in the stacktrace, but from the code it could be the same database field.

The log warning should be done when T275704 is fixed