Page MenuHomePhabricator

Wikibase crashes when serialized data of the entity using foreign entities is loaded from cache.
Closed, ResolvedPublic

Description

When cached version of the MediaInfo entity using foreign properties and items in its statements is fetched from cache, Wikibase crashes while trying to deserialize the cached version:

[a3ca54a981124c4be1b6e4b8] /wiki/Special:EntityData/M5.rdf DataValues\IllegalValueException from line 66 of /vagrant/mediawiki/extensions/WikibaseMediaInfo/vendor/wikibase/data-model/src/Entity/EntityIdValue.php: Invalid EntityIdValue serialization.

Backtrace:

#0 [internal function]: Wikibase\DataModel\Entity\EntityIdValue->unserialize(string)
#1 /vagrant/mediawiki/extensions/WikibaseMediaInfo/vendor/wikibase/data-model/src/Snak/PropertyValueSnak.php(67): unserialize(string)
#2 /vagrant/mediawiki/includes/libs/objectcache/RedisBagOStuff.php(334): Wikibase\DataModel\Snak\PropertyValueSnak->unserialize(string)
#3 /vagrant/mediawiki/includes/libs/objectcache/RedisBagOStuff.php(97): RedisBagOStuff->unserialize(string)
#4 /vagrant/mediawiki/includes/libs/objectcache/BagOStuff.php(185): RedisBagOStuff->doGet(string, integer)
#5 /vagrant/mediawiki/extensions/Wikibase/lib/includes/Store/CachingEntityRevisionLookup.php(116): BagOStuff->get(string)
#6 /vagrant/mediawiki/extensions/Wikibase/lib/includes/Store/CachingEntityRevisionLookup.php(154): Wikibase\Lib\Store\CachingEntityRevisionLookup->getEntityRevision(Wikibase\MediaInfo\DataModel\MediaInfoId, integer, string)
#7 /vagrant/mediawiki/extensions/Wikibase/lib/includes/Store/CachingEntityRevisionLookup.php(136): Wikibase\Lib\Store\CachingEntityRevisionLookup->fetchEntityRevision(Wikibase\MediaInfo\DataModel\MediaInfoId, integer, string)
#8 /vagrant/mediawiki/extensions/Wikibase/repo/includes/LinkedData/EntityDataRequestHandler.php(345): Wikibase\Lib\Store\CachingEntityRevisionLookup->getEntityRevision(Wikibase\MediaInfo\DataModel\MediaInfoId, integer)
#9 /vagrant/mediawiki/extensions/Wikibase/repo/includes/LinkedData/EntityDataRequestHandler.php(415): Wikibase\Repo\LinkedData\EntityDataRequestHandler->getEntityRevision(Wikibase\MediaInfo\DataModel\MediaInfoId, integer)
#10 /vagrant/mediawiki/extensions/Wikibase/repo/includes/LinkedData/EntityDataRequestHandler.php(236): Wikibase\Repo\LinkedData\EntityDataRequestHandler->showData(WebRequest, OutputPage, string, Wikibase\MediaInfo\DataModel\MediaInfoId, integer)
#11 /vagrant/mediawiki/extensions/Wikibase/repo/includes/Specials/SpecialEntityData.php(156): Wikibase\Repo\LinkedData\EntityDataRequestHandler->handleRequest(string, WebRequest, OutputPage)
#12 /vagrant/mediawiki/includes/specialpage/SpecialPage.php(522): Wikibase\Repo\Specials\SpecialEntityData->execute(string)
#13 /vagrant/mediawiki/includes/specialpage/SpecialPageFactory.php(576): SpecialPage->run(string)
#14 /vagrant/mediawiki/includes/MediaWiki.php(285): SpecialPageFactory::executePath(Title, RequestContext)
#15 /vagrant/mediawiki/includes/MediaWiki.php(860): MediaWiki->performRequest()
#16 /vagrant/mediawiki/includes/MediaWiki.php(521): MediaWiki->main()
#17 /vagrant/mediawiki/index.php(43): MediaWiki->run()
#18 /var/www/w/index.php(5): include(string)
#19 {main}

Looking at the cached EntityIdValue in the cache the problem appears to be foreign IDs being serialized incorrectly (as below)

{i:0;i:2;i:1;C:39:\"Wikibase\\DataModel\\Entity\\EntityIdValue\":10:{[\"item\",0]}}

This should be fixed in Wikibase Data Model 7.0.0 (in particular 614ebfb3a1f14a6b57d6edb7a007e9ef2ab1aec5 changing above serialization of EntityIdValue to use full serialized ID ) .
If the issue is not solved after Wikibase starts using the new Data Model version (T157965), this ticket's priority should be bumped high, and the issue should be investigated further.

This issue has been also previously noticed by @daniel (see T157442#3010292)

Patch for review:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 15 2017, 12:45 PM
WMDE-leszek triaged this task as High priority.Mar 15 2017, 12:46 PM
WMDE-leszek updated the task description. (Show Details)
WMDE-leszek added a project: Wikidata.
daniel added a comment.EditedMar 16 2017, 8:58 PM

DataModel 7 fix this issue mostly, but does not have good test coverage for the cause. See https://github.com/wmde/WikibaseDataModel/pull/728

That PR also makes sure JSON serialization works for custom entities that do not suport numeric IDs.

Note that this bug is also triggered by all custom entity IDs, foreign or not.

daniel updated the task description. (Show Details)
daniel lowered the priority of this task from High to Medium.Mar 16 2017, 9:20 PM

Reducing prio to "normal", since the issue should be fixed by the 7.0 release. Custom entity support and test coverage should however be improved, so it's not low.

WMDE-leszek removed WMDE-leszek as the assignee of this task.Mar 21 2017, 8:52 AM

Github patch got merged. So this is now done, right @daniel ?

@WMDE-leszek should be done, but needs manual verification.

WMDE-leszek closed this task as Resolved.Apr 3 2017, 8:16 AM
WMDE-leszek claimed this task.
WMDE-leszek moved this task from Review to Done on the Wikidata-Former-Sprint-Board board.

I've checked this fixed the issue on Wikibase instances we've installed on Labs. It used to crash over there, now it looks OK. I'd then say, this is fixed.