Page MenuHomePhabricator

autoCreateUser fails on a Interwiki Wiki's with shared database
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • two wiki's in different languages (i.e. german/english) connected thru Interwiki links
  • the database is shared using $wgSharedDB parameter (both wiki's have the same database name shared $wgSharedDB=zeus_de;)
  • some tables are already shared (although $wgSharedDB defaults to the 'user' and 'user_properties'):

$wgSharedTables = [ 'user', 'user_groups', 'user_properties', 'interwiki' ];

  • the test user exists on shared database
mysql> use zeus_de;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from user where user_id=3453;
+---------+---------------+----------------+---------------+------------------+-------------------+-------------------------------+----------------+----------------------------------+--------------------------+----------------------------------+--------------------------+-------------------+----------------+-----------------------+
| user_id | user_name     | user_real_name | user_password | user_newpassword | user_newpass_time | user_email                    | user_touched   | user_token                       | user_email_authenticated | user_email_token                 | user_email_token_expires | user_registration | user_editcount | user_password_expires |
+---------+---------------+----------------+---------------+------------------+-------------------+-------------------------------+----------------+----------------------------------+--------------------------+----------------------------------+--------------------------+-------------------+----------------+-----------------------+
|    3453 | Andreas.dietz | Andreas        |               |                  | NULL              | andreas.dietz@uni-konstanz.de | 20250320152558 | 076598d6e900ba400817cd8496812fa7 | 20250320131728           |                                  | NULL                     | 20250320131728    |              1 | NULL                  |
+---------+---------------+----------------+---------------+------------------+-------------------+-------------------------------+----------------+----------------------------------+--------------------------+----------------------------------+--------------------------+-------------------+----------------+-----------------------+
1 row in set (0.00 sec)
  • the Authorization is performed using the SimpleSAMLphp extension (in conjunction with PluggableAuth)

What happens?:

The login will fail on the second Wiki with the following error:

Internal error
[26de4b5c2e2ea62bd661dcbc] /index.php?title=Special:UserLogin&returnto=Main+Page MWException: User::addToDatabase: hit a key conflict attempting to insert user 'Unknown user' row, but it was not present in select!

Backtrace:

from /var/www/html/includes/user/User.php(2797)
#0 /var/www/html/includes/libs/rdbms/database/Database.php(2753): User->{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#1 /var/www/html/includes/libs/rdbms/database/DBConnRef.php(103): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#2 /var/www/html/includes/libs/rdbms/database/DBConnRef.php(665): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#3 /var/www/html/includes/user/User.php(2810): Wikimedia\Rdbms\DBConnRef->doAtomicSection(string, Closure)
#4 /var/www/html/includes/auth/AuthManager.php(1874): User->addToDatabase()
#5 /var/www/html/includes/auth/AuthManager.php(712): MediaWiki\Auth\AuthManager->autoCreateUser(User, string, boolean)
#6 /var/www/html/includes/specialpage/AuthManagerSpecialPage.php(374): MediaWiki\Auth\AuthManager->continueAuthentication(array)
#7 /var/www/html/includes/specialpage/AuthManagerSpecialPage.php(504): AuthManagerSpecialPage->performAuthenticationStep(string, array)
#8 /var/www/html/includes/htmlform/HTMLForm.php(729): AuthManagerSpecialPage->handleFormSubmit(array, VFormHTMLForm)
#9 /var/www/html/includes/specialpage/AuthManagerSpecialPage.php(435): HTMLForm->trySubmit()
#10 /var/www/html/includes/specialpage/LoginSignupSpecialPage.php(320): AuthManagerSpecialPage->trySubmit()
#11 /var/www/html/includes/specialpage/SpecialPage.php(701): LoginSignupSpecialPage->execute(NULL)
#12 /var/www/html/includes/specialpage/SpecialPageFactory.php(1428): SpecialPage->run(NULL)
#13 /var/www/html/includes/MediaWiki.php(316): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#14 /var/www/html/includes/MediaWiki.php(904): MediaWiki->performRequest()
#15 /var/www/html/includes/MediaWiki.php(562): MediaWiki->main()
#16 /var/www/html/index.php(50): MediaWiki->run()
#17 /var/www/html/index.php(46): wfIndexMain()
#18 {main}

What should have happened instead?:

The login to succeed on both wiki's.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

MW 1.39

Other information (browser name/version, screenshots, etc.):

Event Timeline

This seems similar to https://phabricator.wikimedia.org/T299766 - you need to share the 'actor' table as well (and need to run a rather hairy migration, see the linked issue for a script that does that).

S0ring claimed this task.

Sharing the 'actor' table only was sufficient to fix the error, thank you!