Page MenuHomePhabricator

CentralAuth makes phpunit.php crash with an exception
Open, Needs TriagePublic

Description

I installed a fresh copy of MediaWiki twice, and called the two wikis enwiki and metawiki. Using the LocalSettings.php file for each wiki, phpunit.php would pass without any errors or failures.

Then I ran the maintenance scripts in CentralAuth to migrate the accounts, and used this LocalSettings.php file: P6911

Now phpunit.php does not even complete. At around 49% it crashes with the following exception:

[38b60820dc74538bf26fcc20] [no req]   MWException from line 4194 of /var/www/html/includes/user/User.php: CAS update failed on user_touched for user ID '1' (read from master); the version of the user to be saved is older than the current version.
Backtrace:
#0 [internal function]: User->{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#1 /var/www/html/includes/libs/rdbms/database/Database.php(3369): call_user_func_array(Closure, array)
#2 /var/www/html/includes/user/User.php(4208): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#3 /var/www/html/tests/phpunit/includes/TestUser.php(81): User->saveSettings()
#4 /var/www/html/tests/phpunit/includes/TestUserRegistry.php(87): TestUser->__construct(string, string, string, array, string)
#5 /var/www/html/tests/phpunit/MediaWikiTestCase.php(153): TestUserRegistry::getImmutableTestUser(array)
#6 /var/www/html/tests/phpunit/MediaWikiTestCase.php(177): MediaWikiTestCase::getTestUser(array)
#7 /var/www/html/tests/phpunit/MediaWikiTestCase.php(1087): MediaWikiTestCase::getTestSysop()
#8 /var/www/html/tests/phpunit/MediaWikiTestCase.php(1474): MediaWikiTestCase->addCoreDBData()
#9 /var/www/html/tests/phpunit/MediaWikiTestCase.php(423): MediaWikiTestCase->resetDB(Wikimedia\Rdbms\DatabaseMysqli, array)
#10 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(722): MediaWikiTestCase->run(PHPUnit_Framework_TestResult)
#11 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(722): PHPUnit_Framework_TestSuite->run(PHPUnit_Framework_TestResult)
#12 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(722): PHPUnit_Framework_TestSuite->run(PHPUnit_Framework_TestResult)
#13 /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(440): PHPUnit_Framework_TestSuite->run(PHPUnit_Framework_TestResult)
#14 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(149): PHPUnit_TextUI_TestRunner->doRun(PHPUnit_Framework_TestSuite, array)
#15 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(100): PHPUnit_TextUI_Command->run(array, boolean)
#16 /var/www/html/tests/phpunit/phpunit.php(134): PHPUnit_TextUI_Command::main()
#17 /var/www/html/maintenance/doMaintenance.php(94): PHPUnitMaintClass->execute()
#18 /var/www/html/tests/phpunit/phpunit.php(173): require(string)
#19 {main}

Running phpunit.php with the --tap option shows the failure happens at this point:

...
ok 8860 - Pbkdf2PasswordTest::testCrypt with data set #0 ('pbkdf2')
ok 8861 - Pbkdf2PasswordTest::testMediaWikiTestCaseParentSetupCalled
ok 8862 - Pbkdf2PasswordTest::testValidCovers
ok 8863 - UserPasswordPolicyTest::testGetPoliciesForUser
[ced4dc722a6ad570c4e67133] [no req]   MWException from line 4194 of /var/www/html/includes/user/User.php: CAS update failed on user_touched for user ID '1' (read from master); the version of the user to be saved is older than the current version.
...

Event Timeline

Huji triaged this task as Medium priority.Mar 28 2018, 2:31 AM
Huji created this task.
Huji renamed this task from CentralAuth makes PHPunit crash with an exception to CentralAuth makes phpunit.php crash with an exception.Mar 28 2018, 2:37 AM
Huji updated the task description. (Show Details)
Krinkle removed a subscriber: Krinkle.Mar 29 2018, 12:28 AM
Huji raised the priority of this task from Medium to High.Jun 10 2018, 2:53 AM

Increasing to high priority, as it essentially makes it impossible for me to run any unit tests locally.

Can you still reproduce this with latest master of MediaWiki core and CentralAuth?

If so, could you narrow down the settings required to trigger it? It seems the tests are passing in Jenkins both for core and for CentralAuth.

Aklapper raised the priority of this task from High to Needs Triage.Aug 6 2018, 10:17 AM
Aklapper added a project: TestMe.

Resetting priority and adding TestMe until Huji answers Krinkle's last question

Huji added a comment.EditedAug 8 2018, 4:19 PM

I used MediaWiki as of e96b9055fbd4658087b99ef35f118bd618cafa26 and CentralAuth as of d43d471d9786777cb0cf2285fb79591175f8641b

I installed two wikis using the web-based installation interface (called enwiki and metawiki, respectively). I used the LocalSettings file for either of them. Then I ran phpunit.php and it passed like a charm.

Now I changed the LocalSettings file to P6911, sourced the central-auth.sql file, and executed GRANT all on centralauth.* to 'root'@'localhost';

Lastly, I ran the following to migrate stuff to the centralauth database:

➜  CentralAuth git:(master) php maintenance/migratePass0.php --wiki=enwiki
CentralAuth migration pass 0:enwiki preparing migration data...enwiki 1 (100.0%) done in 0.0 secs (90.278 accounts/sec).done.%                              ➜  CentralAuth git:(master) php maintenance/migratePass0.php --wiki=metawiki
CentralAuth migration pass 0:metawiki preparing migration data...metawiki 1 (100.0%) done in 0.0 secs (92.798 accounts/sec).done.%                          ➜  CentralAuth git:(master) php maintenance/migratePass1.php --wiki=metawiki
CentralAuth migration pass 1:
Finding accounts which can be migrated without interaction...
2018-08-08 16:08:46 processed 1 usernames (11.5/sec), 0 (0.0%) fully migrated (@ Admin)
done.
➜  CentralAuth git:(master) php maintenance/migratePass1.php --wiki=enwiki  
CentralAuth migration pass 1:
Finding accounts which can be migrated without interaction...
2018-08-08 16:08:50 processed 1 usernames (12.6/sec), 0 (0.0%) fully migrated (@ Admin)
done.

I tried logging into the metawiki and it worked correctly. Now I ran phpunit.php again and this time, it crashed at around 54% with the following error message:

........................................................... 10679 / 19885 ( 53%)
........................................................... 10738 / 19885 ( 54%)
........................................................... 10797 / 19885 ( 54%)
........................................................... 10856 / 19885 ( 54%)
..................................SSSSSSSSSSSSSSS[926f855a3c1bcf5b715138e4] [no req]   MWException from line 4207 of /var/www/html/includes/user/User.php: CAS update failed on user_touched for user ID '1' (read from master); the version of the user to be saved is older than the current version.
Backtrace:
#0 /var/www/html/includes/libs/rdbms/database/Database.php(3731): User->{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#1 /var/www/html/includes/user/User.php(4221): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#2 /var/www/html/tests/phpunit/includes/TestUser.php(83): User->saveSettings()
#3 /var/www/html/tests/phpunit/includes/TestUserRegistry.php(85): TestUser->__construct(string, string, string, array, string)
#4 /var/www/html/tests/phpunit/MediaWikiTestCase.php(160): TestUserRegistry::getImmutableTestUser(array)
#5 /var/www/html/tests/phpunit/MediaWikiTestCase.php(184): MediaWikiTestCase::getTestUser(array)
#6 /var/www/html/tests/phpunit/MediaWikiTestCase.php(1236): MediaWikiTestCase::getTestSysop()
#7 /var/www/html/tests/phpunit/MediaWikiTestCase.php(1801): MediaWikiTestCase->addCoreDBData()
#8 /var/www/html/tests/phpunit/MediaWikiTestCase.php(467): MediaWikiTestCase->resetDB(Wikimedia\Rdbms\DatabaseMysqli, array)
#9 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(755): MediaWikiTestCase->run(PHPUnit\Framework\TestResult)
#10 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(755): PHPUnit\Framework\TestSuite->run(PHPUnit\Framework\TestResult)
#11 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(755): PHPUnit\Framework\TestSuite->run(PHPUnit\Framework\TestResult)
#12 /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(546): PHPUnit\Framework\TestSuite->run(PHPUnit\Framework\TestResult)
#13 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(195): PHPUnit\TextUI\TestRunner->doRun(PHPUnit\Framework\TestSuite, array, boolean)
#14 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(148): PHPUnit\TextUI\Command->run(array, boolean)
#15 /var/www/html/tests/phpunit/phpunit.php(135): PHPUnit\TextUI\Command::main()
#16 /var/www/html/maintenance/doMaintenance.php(94): PHPUnitMaintClass->execute()
#17 /var/www/html/tests/phpunit/phpunit.php(174): require(string)
#18 {main}

I wonder if my LocalSettings.php file is okay though, because when I tried to log into the enwiki, after I submitted the login form I got sent to the metawiki and received an in-wiki error about log tokens. And also, when I log into metawiki I don't get automatically logged into enwiki as well.

Huji triaged this task as High priority.Aug 8 2018, 4:20 PM
Huji removed a project: TestMe.
Huji updated the task description. (Show Details)
Huji raised the priority of this task from High to Needs Triage.Aug 8 2018, 8:43 PM

Per https://www.mediawiki.org/wiki/Bugzilla/Fields#Priority (I originally assigned a priority because I thought I could find and fix the issue, then figured I could not, but forgot to remove priority)

Untracking from T176039, as it presumably isn't due to logic in core, where tests pass (and on Jenkins as well with CA installed).