Page MenuHomePhabricator

CannotCreateActorException: Cannot create an actor for a usable name that is not an existing user: … (via SpecialImportFile)
Open, HighPublicPRODUCTION ERROR

Description

normalized_message
CannotCreateActorException: Cannot create an actor for a usable name that is not an existing user: …
exception.trace
from /srv/mediawiki/php-1.36.0-wmf.30/includes/user/ActorStore.php(341)
#0 /srv/mediawiki/php-1.36.0-wmf.30/includes/ActorMigration.php(364): MediaWiki\User\ActorStore->acquireActorId(User, Wikimedia\Rdbms\DatabaseMysqli)
#1 /srv/mediawiki/php-1.36.0-wmf.30/includes/Revision/RevisionStore.php(650): ActorMigration->getInsertValuesWithTempTable(Wikimedia\Rdbms\DatabaseMysqli, string, User)
#2 /srv/mediawiki/php-1.36.0-wmf.30/includes/Revision/RevisionStore.php(505): MediaWiki\Revision\RevisionStore->insertRevisionRowOn(Wikimedia\Rdbms\DatabaseMysqli, MediaWiki\Revision\MutableRevisionRecord, integer)
#3 /srv/mediawiki/php-1.36.0-wmf.30/includes/Revision/RevisionStore.php(444): MediaWiki\Revision\RevisionStore->insertRevisionInternal(MediaWiki\Revision\MutableRevisionRecord, Wikimedia\Rdbms\DatabaseMysqli, User, CommentStoreComment, Title, integer, integer)
#4 /srv/mediawiki/php-1.36.0-wmf.30/includes/libs/rdbms/database/Database.php(4500): MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#5 /srv/mediawiki/php-1.36.0-wmf.30/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#6 /srv/mediawiki/php-1.36.0-wmf.30/includes/libs/rdbms/database/DBConnRef.php(641): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#7 /srv/mediawiki/php-1.36.0-wmf.30/includes/Revision/RevisionStore.php(446): Wikimedia\Rdbms\DBConnRef->doAtomicSection(string, Closure)
#8 /srv/mediawiki/php-1.36.0-wmf.30/includes/import/ImportableOldRevisionImporter.php(197): MediaWiki\Revision\RevisionStore->insertRevisionOn(MediaWiki\Revision\MutableRevisionRecord, Wikimedia\Rdbms\DBConnRef)
#9 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/Operations/TextRevisionFromTextRevision.php(127): ImportableOldRevisionImporter->import(WikiRevision)
#10 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/Data/ImportOperations.php(133): FileImporter\Operations\TextRevisionFromTextRevision->commit()
#11 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/Data/ImportOperations.php(82): FileImporter\Data\ImportOperations->FileImporter\Data\{closure}(FileImporter\Operations\TextRevisionFromTextRevision)
#12 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/Data/ImportOperations.php(134): FileImporter\Data\ImportOperations->runOperations(integer, integer, boolean, Closure)
#13 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/Services/Importer.php(310): FileImporter\Data\ImportOperations->commit()
#14 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/Services/Importer.php(174): FileImporter\Services\Importer->commitImportOperations(FileImporter\Data\ImportOperations)
#15 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/SpecialImportFile.php(335): FileImporter\Services\Importer->import(User, FileImporter\Data\ImportPlan)
#16 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/SpecialImportFile.php(236): FileImporter\SpecialImportFile->doImport(FileImporter\Data\ImportPlan)
#17 /srv/mediawiki/php-1.36.0-wmf.30/extensions/FileImporter/src/SpecialImportFile.php(201): FileImporter\SpecialImportFile->handleAction(string, FileImporter\Data\ImportPlan)
#18 /srv/mediawiki/php-1.36.0-wmf.30/includes/specialpage/SpecialPage.php(645): FileImporter\SpecialImportFile->execute(NULL)
#19 /srv/mediawiki/php-1.36.0-wmf.30/includes/specialpage/SpecialPageFactory.php(1405): SpecialPage->run(NULL)
#20 /srv/mediawiki/php-1.36.0-wmf.30/includes/MediaWiki.php(310): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#21 /srv/mediawiki/php-1.36.0-wmf.30/includes/MediaWiki.php(944): MediaWiki->performRequest()
#22 /srv/mediawiki/php-1.36.0-wmf.30/includes/MediaWiki.php(548): MediaWiki->main()
#23 /srv/mediawiki/php-1.36.0-wmf.30/index.php(53): MediaWiki->run()
#24 /srv/mediawiki/php-1.36.0-wmf.30/index.php(46): wfIndexMain()
#25 /srv/mediawiki/w/index.php(3): require(string)
#26 {main}
Impact
Notes

Details

Request ID
YC1o8-@BS9zA7K8jKQI-iQAAAJU
Request URL
https://commons.wikimedia.org/wiki/Special:ImportFile

Event Timeline

Krinkle added a subscriber: Ammarpad.

@Ammarpad I tagged Export-Import as the error was observed while using the Import feature. That's usually where I'd expect investigation to begin. However, I suppose given how little that has changed over the years, and the fact that RevisionStore and the Actor system are relatively new, it's not unlikely that the problem might be there instead. Is that why you untagged it?

I'll tag Revision-backend and User-management (which encompasses RevisionStore as inserter; and ActorStore as receiver), both of which are owned by PET.

Most certaintly caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/661572 - we've actually started using UserIdentityValue and actors in revision store. The patch though tried to preserve existing behavior as much as possible. Investigating. If there's no clear fix from me, reverting the patch should fix the issue.

@Krinkle, In my understanding, this error is not related to mediawiki core import-export feature, the error is from the file import feature of FileImporter extension. A recent User-related core change may play a role here, but even then that's likely unrelated to MediaWiki-Core-Snapshots since the extension is not using that logic.

Krinkle renamed this task from CannotCreateActorException: Cannot create an actor for a usable name that is not an existing user: … (via SpecialImport.php) to CannotCreateActorException: Cannot create an actor for a usable name that is not an existing user: … (via SpecialImportFile).Feb 17 2021, 10:19 PM

I was wrong instantly blaming ActorStore refactoring. I can find these exceptions going back 3 months: https://logstash.wikimedia.org/goto/084bc5924b86526d7d37a5ca10cb34fa

This could be a race condition. Currently, we do the following when creating actor:

  1. try to select for existing actor on master
  2. if not found - verify the actor will have a user_id set if the name is a usable name -> this is where it throws now
  3. write new row to actor table
  4. check for affected rows - if it's zero and the insert failed, try reading again, but now use LOCK IN SHARED MODE.

I believe the same race condition that forced adding the final read fallback could be hitting, and forcing us to throw an exception.

All the cases share more or less the same stack trace and are all coming from FileImporter. And it seems like in this case files were imported by users who didn't have commons local account, so it was should have been auto created just before trying to use it

Change 664953 had a related patch set uploaded (by Ppchelko; owner: Ppchelko):
[mediawiki/core@master] ActorStore: try locking read before crashing request

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

Some more log context when this happens:

Mar 12, 2021 @ 11:32:17.025	mediawiki	mw1266	[YEtRPL6gBC9b0POalL@nUgAAABg] /wiki/Special:ImportFile   CannotCreateActorException: Cannot create an actor for a usable name that is not an existing user: user_name="REDACTED"
	Mar 12, 2021 @ 11:32:13.404	mediawiki	mw1266	MediaWiki\Auth\AuthManager::autoCreateUser: REDACTED already exists locally (race)
	Mar 12, 2021 @ 11:32:13.402	mediawiki	mw1266	MediaWiki\Auth\AuthManager::autoCreateUser: creating new user (REDACTED) - from: /wiki/Special:ImportFile
	Mar 12, 2021 @ 11:32:06.110	mediawiki	mw1264	Couldn't find a global ID for user REDACTED
	Mar 12, 2021 @ 11:32:05.992	mediawiki	mw1264	Couldn't find a global ID for user REDACTED
	Mar 12, 2021 @ 11:32:05.982	mediawiki	mw1264	Attaching local user REDACTED@commonswiki by 'login'
	Mar 12, 2021 @ 11:32:05.978	mediawiki	mw1264	Couldn't find a global ID for user REDACTED

Change 664953 abandoned by Ppchelko:

[mediawiki/core@master] ActorStore: bypass repeatable read snapshot when creating actor.

Reason:

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

Change 690583 had a related patch set uploaded (by Ppchelko; author: Ppchelko):

[mediawiki/core@master] ActorStore: Try fetching actor id from master before throwing

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