Last modified: 2014-11-12 01:12:34 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T75139, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 73139 - SiteSQLStoreTest::testGetSites fails with 'null value in column "site_id" violates not-null constraint'
SiteSQLStoreTest::testGetSites fails with 'null value in column "site_id" vio...
Status: NEW
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
1.25-git
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: postgres 73175
  Show dependency treegraph
 
Reported: 2014-11-07 17:22 UTC by Jeff Janes
Modified: 2014-11-12 01:12 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jeff Janes 2014-11-07 17:22:37 UTC
Change-Id I3f47675646d772 converts from explicit transactions to using "startAtomic", which according to the documentation is more strict than directly using transactions. 

This breaks phpunit tests for PostgreSQL.  Not just a specific test fails, rather it breaks the testing framework itself.

I don't know where this bug might be, I suspect there might more than one of them involved..  It seems like, if nothing else, the unit test should at least catch the error and report it, rather than aborting the test sequence.  But I don't why it isn't doing that.

PHP Notice:  DatabasePostgres::reportQueryError: Explicit rollback of implicit transaction. Something may be out of sync! [Called from DatabaseBase::rollback in /usr/local/apache2/htdocs/wiki_git/includes/db/Database.php at line 3620] in /usr/local/apache2/htdocs/wiki_git/includes/debug/MWDebug.php on line 302
PHP Stack trace:
PHP   1. {main}() /usr/local/apache2/htdocs/wiki_git/tests/phpunit/phpunit.php:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/local/apache2/htdocs/wiki_git/tests/phpunit/phpunit.php:233
PHP   3. PHPUnit_TextUI_Command->run() /usr/local/apache2/htdocs/wiki_git/vendor/phpunit/phpunit/src/TextUI/Command.php:138
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/local/apache2/htdocs/wiki_git/vendor/phpunit/phpunit/src/TextUI/Command.php:186
PHP   5. PHPUnit_Framework_TestSuite->run() /usr/local/apache2/htdocs/wiki_git/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP   6. PHPUnit_Framework_TestSuite->run() /usr/local/apache2/htdocs/wiki_git/vendor/phpunit/phpunit/src/Framework/TestSuite.php:751
PHP   7. PHPUnit_Framework_TestSuite->run() /usr/local/apache2/htdocs/wiki_git/vendor/phpunit/phpunit/src/Framework/TestSuite.php:751
PHP   8. MediaWikiTestCase->run() /usr/local/apache2/htdocs/wiki_git/vendor/phpunit/phpunit/src/Framework/TestSuite.php:751
PHP   9. MediaWikiTestCase->addCoreDBData() /usr/local/apache2/htdocs/wiki_git/tests/phpunit/MediaWikiTestCase.php:133
PHP  10. User->idForName() /usr/local/apache2/htdocs/wiki_git/tests/phpunit/MediaWikiTestCase.php:470
PHP  11. DatabaseBase->selectField() /usr/local/apache2/htdocs/wiki_git/includes/User.php:3526
PHP  12. DatabaseBase->select() /usr/local/apache2/htdocs/wiki_git/includes/db/Database.php:1360
PHP  13. DatabaseBase->query() /usr/local/apache2/htdocs/wiki_git/includes/db/Database.php:1650
PHP  14. DatabasePostgres->reportQueryError() /usr/local/apache2/htdocs/wiki_git/includes/db/Database.php:1182
PHP  15. DatabaseBase->rollback() /usr/local/apache2/htdocs/wiki_git/includes/db/DatabasePostgres.php:536
PHP  16. wfWarn() /usr/local/apache2/htdocs/wiki_git/includes/db/Database.php:3620
PHP  17. MWDebug::warning() /usr/local/apache2/htdocs/wiki_git/includes/GlobalFunctions.php:1159
PHP  18. MWDebug::sendMessage() /usr/local/apache2/htdocs/wiki_git/includes/debug/MWDebug.php:157
PHP  19. trigger_error() /usr/local/apache2/htdocs/wiki_git/includes/debug/MWDebug.php:302
A database query error has occurred.
Query: SELECT  user_id  FROM "unittest_mwuser"   WHERE user_name = 'UTSysop'  LIMIT 1
Function: User::idForName
Error: 25P02 ERROR:  current transaction is aborted, commands ignored until end of transaction block
Comment 1 Tim Landscheidt 2014-11-11 01:46:23 UTC
Indeed master + Jeff's Gerrit change #170395 fails (cf. https://travis-ci.org/scfc/mediawiki-core/jobs/40611418).

Marcin, IIRC you fixed a lot of transaction-related PostgreSQL bugs many moons ago; do you have a grasp of the current design?
Comment 2 Marcin Cieślak 2014-11-11 21:41:07 UTC
do we know which test is causing this?
Comment 3 Marcin Cieślak 2014-11-11 21:58:26 UTC
With current master (and a change to nuke INSERT IGNORE in the updater) I am running

php tests/phpunit/phpunit.php --configuration tests/phpunit/suite.xml --exclude-group Broken,Stub,Dump,ParserFuzz

and I get

5 errors:

1) ImportTest::testHandlePageContainsRedirect with data set #0 ('<mediawiki ...

MWException: Cannot create InputStreamSource.

2) ImportTest::testHandlePageContainsRedirect with data set #1

MWException: Cannot create InputStreamSource.

3) TestORMRowTest::testSaveAndRemove

which is bug 43475

4) SiteSQLStoreTest::testGetSites
DBQueryError: A database error has occurred. Did you forget to run maintenance/update.php after upgrading?  See: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script
Query: INSERT INTO "unittest_sites" (site_id,site_global_key,site_type,site_group,site_source,site_language,site_protocol,site_domain,site_data,site_forward,site_config) VALUES (NULL,'foobar','unknown','none','local','','','.','a:0:{}',0,'a:0:{}')
Function: SiteSQLStore::saveSites
Error: 23502 ERROR:  null value in column "site_id" violates not-null constraint

which is probably what we are getting here?

5) SiteSQLStoreTest::testSaveSites
DBQueryError: A database error has occurred. Did you forget to run maintenance/update.php after upgrading?  See: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script
Query: INSERT INTO "unittest_sites" (site_id,site_global_key,site_type,site_group,site_source,site_language,site_protocol,site_domain,site_data,site_forward,site_config) VALUES (NULL,'ertrywuutr','unknown','none','local','en','','.','a:0:{}',0,'a:0:{}')
Function: SiteSQLStore::saveSites
Error: 23502 ERROR:  null value in column "site_id" violates not-null constraint

and then 18 test failures:

1) PrefixSearchTest::testSearch
2) SpecialPageTest::testInvalidGetTitleFor
Failed asserting that exception of type "PHPUnit_Framework_Error_Notice" is thrown.
3) SpecialPageTest::testGetTitleForWithWarning with data set #0 (Special:UserLogin, 'UserLogin')
Failed asserting that exception of type "PHPUnit_Framework_Error_Notice" is thrown.

4) WikiPageTest::testDoDeleteArticle
5) WikiPageTest::testDoDeleteUpdates

known issues

6) SiteSQLStoreTest::testReset

probably related to the error above

and some TextPassDumperTest and FetchTextTest failures

15 tests were skipped
Comment 4 Jeff Janes 2014-11-11 23:08:03 UTC
The test that fails is:

php tests/phpunit/phpunit.php tests/phpunit/includes/site/SiteSQLStoreTest.php

Only it presents differently for me, taking down the test framework rather than just failing in the ordinary way.

I wonder if the behavior depends on the version of the php library used to talk to pgsql.  I don't know how to figure that out.  I'm using CentOS 6.6 and PHP 5.3.3 (cli) (built: Oct 30 2014 20:12:53).
Comment 5 Marcin Cieślak 2014-11-11 23:17:06 UTC
First I have you run into the issue (which got fixed in the meantime) that the transaction error overshadowed any real database error during testing - this was I think bug 58095.

on my installation it seems that the problem is with SiteSQLStoreTest - 
after applying by hand my fix in Gerrit change #100183.

Actually those problems were already mentioned in bug 43475

Can we check if teaching "ORM" to use sequences fixes the problem?
Comment 6 Marcin Cieślak 2014-11-11 23:18:11 UTC
Please try Gerrit change #100183 - it should fix this (and some other "ORM" tests as well).
Comment 7 Jeff Janes 2014-11-12 00:25:08 UTC
Gerrit change #100183 fixes the distal problem, but not the proximal problem that the test suite should not fall over when one test in it fails.  

Bug 58095 is marked closed, should that be reopened?
Comment 8 Marcin Cieślak 2014-11-12 01:12:34 UTC
Can we double check if fix for bug 58095 (Gerrit change #136287 - it's yours) is included in our build on travis?

I wonder why it works for me...

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links