Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MW 1.31 ALL postgres tests are broken!! #3101

Closed
mwjames opened this issue Apr 7, 2018 · 6 comments
Closed

MW 1.31 ALL postgres tests are broken!! #3101

mwjames opened this issue Apr 7, 2018 · 6 comments

Comments

@mwjames
Copy link
Contributor

mwjames commented Apr 7, 2018

Running a weekly test sprint on mw-master/postgres locally I found that [0] broke the entire setup for almost every test.

Using PHP 7.1.1

Semantic MediaWiki: 3.0.0-alpha, 01f773e, {"store":"SMWSQLStore3","db":"postgres"}
MediaWiki:          1.31.0-alpha, e9553f6, MediaWiki vendor autoloader
Site language:      en

Execution time:     2018-04-07 02:13
Debug logs:         Disabled
Xdebug:             Disabled (or not installed)

PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

Runtime:        PHP 7.1.1
Configuration:  D:\xampp\htdocs\mw-master-pg\extensions\SemanticMediaWiki\phpunit.xml.dist

..F.....F...................................................   60 / 6295 (  0%)
............................................................  120 / 6295 (  1%)
..............SSSSSSSSSSS...................................  180 / 6295 (  2%)
.....EE.EEEE.EE.............................................  240 / 6295 (  3%)
......................................EEEEEEEEEEEEEEEEEEEEEE  300 / 6295 (  4%)
EEEEEEEEEEEEEEE.SSSSSS............................S.......SS  360 / 6295 (  5%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.........SSSSSSSS......EEEE  420 / 6295 (  6%)
EEEEE.........EE.....................................EE.EEEE  480 / 6295 (  7%)
EEEE...EE..E................................................  540 / 6295 (  8%)
............................................................  600 / 6295 (  9%)
............................................................  660 / 6295 ( 10%)
........ESSEEEEEEEEEEEEEEEEEEEEEE..EEEE.....................  720 / 6295 ( 11%)
...............SSSSSSSSSS...................................  780 / 6295 ( 12%)
............................................................  840 / 6295 ( 13%)
....................................EEEEEE..E...............  900 / 6295 ( 14%)
.............EEEEEEEEEEEEEEEEEEE.....................EE.E.E.  960 / 6295 ( 15%)
......................................................E..... 1020 / 6295 ( 16%)
.........E.EEE..EE..............................EEEEEE..EEEE 1080 / 6295 ( 17%)
EEEE........................................................ 1140 / 6295 ( 18%)
................................................EEEEE....... 1200 / 6295 ( 19%)
.....................E...................EEEEEEEEEEE........ 1260 / 6295 ( 20%)
............................................................ 1320 / 6295 ( 20%)
......................................E..................... 1380 / 6295 ( 21%)
............................................................ 1440 / 6295 ( 22%)
............................................................ 1500 / 6295 ( 23%)
...........EEEEEEEEE........................................ 1560 / 6295 ( 24%)
.EE......................................................... 1620 / 6295 ( 25%)
............................................EE...........E.E 1680 / 6295 ( 26%)
............................................................ 1740 / 6295 ( 27%)
...............................................E.....E...EE. 1800 / 6295 ( 28%)
...EE.EE.....E..E.E...........E............................. 1860 / 6295 ( 29%)
..............EE.......EEEEEEEE..EE........EEEE............. 1920 / 6295 ( 30%)
...................................E........................ 1980 / 6295 ( 31%)
............................................................ 2040 / 6295 ( 32%)
................EEEEEEE.EEEE................................ 2100 / 6295 ( 33%)
.................................E.EE....................... 2160 / 6295 ( 34%)
............................................................ 2220 / 6295 ( 35%)
............................................................ 2280 / 6295 ( 36%)
.......SSSS..E...............E...........................EE. 2340 / 6295 ( 37%)
.........E.....EEEEEEEEE.EEE.....E...E...EEEEEEE...E........ 2400 / 6295 ( 38%)
........................................E......E.E.EE.EEE.E. 2460 / 6295 ( 39%)
EEEEEEEEEE..............EE.E.EEEE.....E.EEEE.E..EEEE........ 2520 / 6295 ( 40%)
............E............................................... 2580 / 6295 ( 40%)
......................................................EE.... 2640 / 6295 ( 41%)
.............................................E.............. 2700 / 6295 ( 42%)
............................................................ 2760 / 6295 ( 43%)
...............EEE.............E...EE....................... 2820 / 6295 ( 44%)
..EFEEE...EE...FF..E.EFEE......EE........................... 2880 / 6295 ( 45%)
...........................................E..E............. 2940 / 6295 ( 46%)
.....EEEEEEEEEE.EE.....EEEEEEEEEEEEEEEEE.EEEEEE.E.EEEEEEEEEE 3000 / 6295 ( 47%)
EEE...EEE.EEE.E........EEEEEEEEEEEE.EEEEEEEEE.EE.EEEEEEEEEEE 3060 / 6295 ( 48%)
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE................... 3120 / 6295 ( 49%)
..............................EEEEEEEEEEEEEEEE.EEEEEEEEEEEEE 3180 / 6295 ( 50%)
EEEEEEEEEEE...............................................E. 3240 / 6295 ( 51%)
...............................................E..E...E..... 3300 / 6295 ( 52%)
.......................................EEEE...E............. 3360 / 6295 ( 53%)
.................................EE......................... 3420 / 6295 ( 54%)
E............EE............................................. 3480 / 6295 ( 55%)
............................................................ 3540 / 6295 ( 56%)
........................E.............F..................... 3600 / 6295 ( 57%)
............................................................ 3660 / 6295 ( 58%)
............................................................ 3720 / 6295 ( 59%)
............................................................ 3780 / 6295 ( 60%)
............................................................ 3840 / 6295 ( 61%)
............................................................ 3900 / 6295 ( 61%)
............................................................ 3960 / 6295 ( 62%)
............................................................ 4020 / 6295 ( 63%)
............................................................ 4080 / 6295 ( 64%)
.E.EEE....EE.................................EE............. 4140 / 6295 ( 65%)
............................................................ 4200 / 6295 ( 66%)
............................................................ 4260 / 6295 ( 67%)
........................SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 4320 / 6295 ( 68%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 4380 / 6295 ( 69%)
............E.EE.E.......................................... 4440 / 6295 ( 70%)
............................................................ 4500 / 6295 ( 71%)
............................................................ 4560 / 6295 ( 72%)
............................................................ 4620 / 6295 ( 73%)
............................................................ 4680 / 6295 ( 74%)
............................................................ 4740 / 6295 ( 75%)
............................................................ 4800 / 6295 ( 76%)
...........................................................E 4860 / 6295 ( 77%)
............................................................ 4920 / 6295 ( 78%)
.......................................SSSSSSSSSSSSSSSSSSSSS 4980 / 6295 ( 79%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 5040 / 6295 ( 80%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 5100 / 6295 ( 81%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 5160 / 6295 ( 81%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 5220 / 6295 ( 82%)
.EEEEEEEEEEEEEESSSSSSSSSSSSSSSSSSSS.SSSSSSSSSSSSSE.......... 5280 / 6295 ( 83%)
.SSSSSSSSSSSSSSSSSSSSSSSSSE.EESS.....SSSSSSSSSSSSSSSSSSSSSSS 5340 / 6295 ( 84%)
SSSSSSSSS.EEEE..ESSSSSSSSSS.........EEEE.EEE.SSSSSSSSSSS.... 5400 / 6295 ( 85%)
............................................................ 5460 / 6295 ( 86%)
............................................................ 5520 / 6295 ( 87%)
............................................................ 5580 / 6295 ( 88%)
............................................................ 5640 / 6295 ( 89%)
............................................................ 5700 / 6295 ( 90%)
............................................................ 5760 / 6295 ( 91%)
............................................................ 5820 / 6295 ( 92%)
............................................................ 5880 / 6295 ( 93%)
............................................................ 5940 / 6295 ( 94%)
............................................................ 6000 / 6295 ( 95%)
............................................................ 6060 / 6295 ( 96%)
............................................................ 6120 / 6295 ( 97%)
............................................................ 6180 / 6295 ( 98%)
...................................................SS....... 6240 / 6295 ( 99%)
....................................................

Time: 1.13 minutes, Memory: 268.00MB

There were 539 errors:

1) SMW\Tests\SQLStore\Writer\ChangeTitleTest::testChangeTitleForMainNamespaceWithoutRedirectId
Wikimedia\Rdbms\DBQueryError: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT  iw_prefix,iw_url,iw_api,iw_wikiid,iw_local,iw_trans  FROM "sunittest_interwiki"    WHERE iw_prefix = 'smw\tests\sqlstore\writer\changetitletest'  LIMIT 1
Function: MediaWiki\Interwiki\{closure}
Error: 42P01 ERROR:  relation "sunittest_interwiki" does not exist
LINE 1: ...x,iw_url,iw_api,iw_wikiid,iw_local,iw_trans  FROM "sunittest...

Going back to [1] restores to last mentioned stats in #2905 (comment).

PS: Seriously, I don't know why this happens every week anew that things are broken beyond an acceptable level. We are all (or most) professionals that now and then make mistakes but this is becoming a constant irritation.

[0] wikimedia/mediawiki@e9553f6
[1] wikimedia/mediawiki@9688e5a

@kghbln kghbln changed the title 1.31 ALL postgres tests are broken!! MW 1.31 ALL postgres tests are broken!! Apr 7, 2018
@cicalese
Copy link
Contributor

cicalese commented Apr 9, 2018

@mwjames, it would help us to know a bit more about the nature of the failures. The patch [0] fixed 10 test errors and 9 failures when run with PostgreSQL, while introducing no new errors or failures in our testing. Compare [1] and [2].

Brad speculates that maybe if you're passing false for $temporary to duplicateTableStructure(), then when CloneDatabase drops the table it won't drop the sequence and a subsequent run might throw an error at the point where it tries to re-create it. That's just a guess, but he has proposed a core patch to address that situation [3].

If that is not the issue, please provide more information.

Please understand that our intent is to improve support for Postgres, not degrade it. You are testing unreleased software, which can be frustrating, and we appreciate your feedback. We will work, as always, to address issues that you find. What is not acceptable, as you know, is to impugn the professionalism of the developers on either side of this interaction.

Cindy

[0] https://gerrit.wikimedia.org/r/#/c/420251/
[1] https://travis-ci.org/wikimedia/mediawiki/jobs/362894696
[2] https://travis-ci.org/wikimedia/mediawiki/jobs/362902022
[3] https://gerrit.wikimedia.org/r/425082

@mwjames
Copy link
Contributor Author

mwjames commented Apr 22, 2018

Please understand that our intent is to improve support

Well, I believe that is the common imperative of software development but when I come back each weekend and see that things are broken again and again I'm questioning that directive.

You are testing unreleased software, which can be frustrating

I'm aware of that and is the reason why we are writing tests which includes tests that are categorized as integration tests and not just unit tests that mock a connection.

If that is not the issue, please provide more information.

I created [0] which runs with [1] (mw-master) and as of this writing [1] reports "There were 101 errors:" which is lower than the initial reported "There were 539 errors:" in numbers but still 101 errors too many. Those errors from [1] don't appear for any other system or release.

To simplify and help the analysis, I also created [2] which runs the same SMW master but uses the MW 1.30 release as base and reports with "1 error" (which is linked to #2903).

This should clarify that whatever changed between MW 1.30 and mw-master creates a massive failure which can not be accounted to SMW as it is used unaltered during the test run.

You are free to use the [0] as branch to switch releases.

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/postgres-issue-3101

[1] https://travis-ci.org/SemanticMediaWiki/SemanticMediaWiki/jobs/369790915

Using PHP 5.6.32
Semantic MediaWiki: 3.0.0-alpha, 168d0bb, {"store":"SMWSQLStore3","db":"postgres"}
MediaWiki:          1.32.0-alpha, N/A, Extension vendor autoloader
Site language:      en
Execution time:     2018-04-22 04:38
Debug logs:         Disabled
Xdebug:             2.5.5

[2] https://travis-ci.org/SemanticMediaWiki/SemanticMediaWiki/jobs/369795775

Using PHP 5.6.32
Semantic MediaWiki: 3.0.0-alpha, a4bbc21, {"store":"SMWSQLStore3","db":"postgres"}
MediaWiki:          1.30.0, N/A, Extension vendor autoloader
Site language:      en
Execution time:     2018-04-22 05:08
Debug logs:         Disabled
Xdebug:             2.5.5

PS: I only respond during a weekend to questions or inquiries.

@cicalese
Copy link
Contributor

cicalese commented Apr 24, 2018

@mwjames, I asked one of our devs to take a look at the 101 remaining errors in the PHPUnit run. A summary of the cause of these errors is as follows:

  • 3 which need one fix on the MediaWiki side (see error # 93 below).
  • 1 deprecated function usage (see error # 45 below).
  • 27 errors in SMW that you are already aware of (see error # 1 below).
  • 70 that should go away when you fix the previous bullet or that you could get rid of sooner by rolling back the database handle in each test's tearDown() if the test left an open transaction (see error # 2 below). OTOH, I can't promise that fixing that won't reveal other errors (especially more instances of the third bullet).

The full analysis of each error follows:

Error # 1: This seems to be the same failure you are already tracking at #2903. You seem to have identified the MediaWiki change that broke SMW's expectations there.

TL;DR: In MySQL, SQLite, and MSSQL, the "sequence" for auto-incrementing ID columns is not separable from the ID column itself, while in PostgreSQL and Oracle the sequence is a separate database object. MediaWiki used to have a method that only needed to be called for PostgreSQL and Oracle to fetch the next ID from the sequence object so it could be used when inserting into the table and known afterwards, meaning that most code forgot to ever call that method because MySQL and Sqlite don't need it. We decided to deprecate and remove that method in favor of having MediaWiki's database later handle it all transparently for PostgreSQL and Oracle.

It seems SMW's tests were somehow or other depending on that separation in PostgreSQL and will need to be fixed.

Chances are there are 27 errors caused by this issue now versus only 1 when running with MediaWiki 1.30 because, prior to https://gerrit.wikimedia.org/r/c/420251/, later tests probably worked because they continued on incrementing the sequence after the one colliding ID instead of resetting the sequence each time the table is re-cloned.

Errors # 2–44: These all seem to be because the database handle is in an error state from # 1 and was never rolled back. This "error state" functionality was added in https://gerrit.wikimedia.org/r/c/421496/ to make handling of database errors less error-prone.

Somewhat ironically, the new behavior matches PostgreSQL's native behavior that MediaWiki had previously been working around in a hacky and half-broken manner.

MediaWiki's MediaWikiTestCase class calls rollback() on the database handle if the test left a transaction open (i.e. because the test failed) so any such error state will get cleared for subsequent tests. But SMW doesn't include that rollback logic in each test's tearDown(), hence the error state persists until a rollback does happen.

Error # 45: This is use of a deprecated function. SMW will need to be updated to not use it.

Error # 46: This is another duplicate ID error, see error # 1.

Errors # 47–73: These all seem to be because the database handle is in an error state from # 46 and was never rolled back. See error # 2.

Errors # 74–92: More duplicate ID errors, see error # 1.

Error # 93: This was caused by a change in MediaWiki, but not in the database layer. When we were updating code related to the import duplicate detection logic, we updated that logic to use the rev_sha1 field added 6 years go. And SMW is using a dump that's older than that in its import tests.

A fix has been submitted to avoid the PostgreSQL database error as https://gerrit.wikimedia.org/r/c/428521/.

Errors # 94–95: More duplicate ID errors, see error # 1 .

Error # 96: Same as error # 93.

Error # 97–99: More duplicate ID errors, see error # 1.

Error # 100: Same as error # 93.

Error # 101: Another duplicate ID error, see error # 1.

@cicalese
Copy link
Contributor

@mwjames Are there any remaining Postgres test failures that you need assistance with?

@kghbln kghbln mentioned this issue Jul 5, 2018
58 tasks
@cicalese
Copy link
Contributor

@mwjames Are there any remaining Postgres test failures that you need assistance with?

@mwjames Just checking in with respect to Postgres. If there are issues that could use attention, please let me know.

@mwjames
Copy link
Contributor Author

mwjames commented Sep 3, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants