Last modified: 2013-04-22 16:16:49 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 T46136, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 44136 - SavepointPostgres tries to rollback already committed/rolled back transactions
SavepointPostgres tries to rollback already committed/rolled back transactions
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
1.21.x
All All
: Normal major (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 44148 (view as bug list)
Depends on:
Blocks: postgres
  Show dependency treegraph
 
Reported: 2013-01-19 00:43 UTC by OverlordQ
Modified: 2013-04-22 16:16 UTC (History)
6 users (show)

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


Attachments
Backtrace from DatabaseBase->rollback context (1.40 KB, text/plain)
2013-01-21 22:13 UTC, OverlordQ
Details
SQL statement logging. (27.90 KB, text/plain)
2013-01-22 15:35 UTC, OverlordQ
Details
Debug Log (205.48 KB, text/plain)
2013-01-22 15:35 UTC, OverlordQ
Details

Description OverlordQ 2013-01-19 00:43:13 UTC
==
php phpunit.php --configuration /var/www/thedarkcitadel.com/w/tests/phpunit/suite.xml  --exclude-group Parser,Broken,ParserFuzz,Stub
PHPUnit 3.6.11 by Sebastian Bergmann.

Configuration read from /var/www/thedarkcitadel.com/w/tests/phpunit/suite.xml

PHP Notice:  DatabaseBase::rollback: No transaction to rollback, something got out of sync! [Called from DatabaseBase::rollback in /var/www/thedarkcitadel.com/w/includes/db/Database.php at line 3088] in /var/www/thedarkcitadel.com/w/includes/debug/Debug.php on line 283

Notice: DatabaseBase::rollback: No transaction to rollback, something got out of sync! [Called from DatabaseBase::rollback in /var/www/thedarkcitadel.com/w/includes/db/Database.php at line 3088] in /var/www/thedarkcitadel.com/w/includes/debug/Debug.php on line 283
PHP Notice:  DatabaseBase::rollback: No transaction to rollback, something got out of sync! [Called from DatabaseBase::rollback in /var/www/thedarkcitadel.com/w/includes/db/Database.php at line 3088] in /var/www/thedarkcitadel.com/w/includes/debug/Debug.php on line 283

Notice: DatabaseBase::rollback: No transaction to rollback, something got out of sync! [Called from DatabaseBase::rollback in /var/www/thedarkcitadel.com/w/includes/db/Database.php at line 3088] in /var/www/thedarkcitadel.com/w/includes/debug/Debug.php on line 283
PHP Notice:  DatabaseBase::rollback: No transaction to rollback, something got out of sync! [Called from DatabaseBase::rollback in /var/www/thedarkcitadel.com/w/includes/db/Database.php at line 3088] in /var/www/thedarkcitadel.com/w/includes/debug/Debug.php on line 283

Notice: DatabaseBase::rollback: No transaction to rollback, something got out of sync! [Called from DatabaseBase::rollback in /var/www/thedarkcitadel.com/w/includes/db/Database.php at line 3088] in /var/www/thedarkcitadel.com/w/includes/debug/Debug.php on line 283
make: *** [noparser] Segmentation fault
==
Comment 1 OverlordQ 2013-01-20 00:56:14 UTC
*** Bug 44148 has been marked as a duplicate of this bug. ***
Comment 2 OverlordQ 2013-01-21 22:12:02 UTC
Trying to get a backtrace from rollback() was semi-successful, steps past #5 contain way to much data for use. I'll attach what I can.  Give that part of the stack includes SavepointPostgres makes me lead to the belief that is is Pg only, and the txlevel is probably not being cleared/set correctly on rollback/commits.
Comment 3 OverlordQ 2013-01-21 22:13:53 UTC
Created attachment 11663 [details]
Backtrace from DatabaseBase->rollback context
Comment 4 OverlordQ 2013-01-21 22:42:48 UTC
Alright, I think I know the issue. 

On line 817 of DatabasePostgres[1] we explicitly call $savepoint->commit() if we have a savepoint, 

SavepointPostgres::commit calls the commit function of the originally passed database handle. This isn't defined IN DatabasePostgres so it uses DatabaseBase::commit which calls DatabaseBase::doCommit which clears out the mTrxLevel and does a 'COMMIT' query.

Then after we return on 837 of DatabasePostgres $savepoint moves out of scope and so it's __destruct method is called.

SavepointPostgres::__destruct only checks $this->didbegin and not against $dbw->trxLevel(). 

In the DatabasePostgres::insert function the savepoint is initialized before the query method, and so in the context of SavepointPostgres::__construct there is no trxLevel yes, and thus sets didbegin.

So when __destruct is called, it calls $dbw->rollback() which throws the error that there is No transaction to rollback as DatabaseBase::commit already committed the transaction.

tl;dr SavepointPostgres::__destruct only checks to see if we started a transaction and not if we're still in one and tries to rollback out of transaction.

It seems bugzilla wont let me CC saper as it's his code, so I will pester on IRC.

1 - https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blame;f=includes/db/DatabasePostgres.php;hb=c15d0a7521231c2cb71e664265e08d0ae514fc73#l817
Comment 5 Marcin Cieślak 2013-01-22 09:12:22 UTC
Here's saper:)

No code is mine :) Before looking into it, quick question:

- what are your cache settings? ($wgMainCacheType and friends?)

- can you have an output from $wgDebugLogFile with $wgDebugDBTransactions enabled?

I get similar problems mostly when something other is accessing database independently and playing with transactions on its own (see bug 27283 for example).
Comment 6 Marcin Cieślak 2013-01-22 10:03:08 UTC
Ok, I think that the problem is because we should reset "didbegin" to false once we commit or rollback the transaction in the context of SavepointPostgres. I just wonder what has changed since this code was introduced. Did INSERT has its own enclosing transaction before, so SavepointPostgres never introduced its own?
Comment 7 OverlordQ 2013-01-22 15:35:24 UTC
Created attachment 11665 [details]
SQL statement logging.

I keep forgetting with gerrit committer may not equal author. 

Cache is CACHE_ACCEL.

Debug Log doesn't have anything helpful in it.
Comment 8 OverlordQ 2013-01-22 15:35:45 UTC
Created attachment 11666 [details]
Debug Log
Comment 9 Marcin Cieślak 2013-01-22 20:14:07 UTC
Thanks, I think I have an easy fix for this.

By the way, there is information in the logs that phpunit.php dumps core at the end. Can you get more information about it like a stackgrace using "gdb <pathtophp> php.core" or something? It might be some instance of bug 43972 and we are still looking for more information about it and we are grateful for infos :)
Comment 10 Marcin Cieślak 2013-01-22 20:56:03 UTC
Some preliminary and untested fix in Gerrit change #45231
Comment 11 Alex Monk 2013-02-03 17:39:26 UTC
Merged by Demon on the 31st. Can someone test this?
Comment 12 Alex Monk 2013-02-16 22:31:50 UTC
In that case, let's mark this as resolved.

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


Navigation
Links