Page MenuHomePhabricator

Referential integrity issues on commons on pages created by API
Closed, ResolvedPublic

Description

These pages https://dpaste.de/Df0x/raw (except for things in namespace 6, which is bug 32551. However that's basically the same bug except for from the runJobs.php entry point instead of api.php entry point)

There's a bunch of pages on commons with no revisions and rev_latest = 0.

I suspect this is caused by differences in uncaught exception handling on the api.php entry point and the index.php entry point.

If there is an open transaction, and then an exception is thrown, but nobody catches it, different things will happen depending on entry point:
*On index.php, transaction will be thrown away (implicitly anyways, basically the shutdown method isn't called)
*On Api.php the following:
$lb = wfGetLBFactory();
$lb->shutdown();

Happens regardless of if there is an uncaught exception, triggering a $dbw->commit even if exception was thrown in middle of transaction.


Version: unspecified
Severity: normal

Details

Reference
bz63145

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 3:06 AM
bzimport added a project: MediaWiki-API.
bzimport set Reference to bz63145.
bzimport added a subscriber: Unknown Object (MLST).
Bawolff created this task.Mar 26 2014, 9:16 PM

This also appears to be happening on wikis other than Commons, though on a much more limited scale than on Commons (one page on frwiki, for instance).

(In reply to Bawolff (Brian Wolff) from comment #0)

*On index.php, transaction will be thrown away (implicitly anyways,
basically the shutdown method isn't called)

That is probably what's behind bug 56269.

Happens regardless of if there is an uncaught exception, triggering a
$dbw->commit even if exception was thrown in middle of transaction.

Yeah, that's no good.

Of course, in both this bug and bug 56269 the real solution is that whatever is opening these transactions should catch, rollback, and rethrow. But uncaught exceptions happen, so the last-resort catch should DTRT and both rollback and log the stack trace of the problematic exception.

Change 121402 had a related patch set uploaded by Anomie:
Improve handling of uncommitted DB txns with "uncaught" exceptions

https://gerrit.wikimedia.org/r/121402

Change 121402 merged by jenkins-bot:
Improve handling of uncommitted DB txns with "uncaught" exceptions

https://gerrit.wikimedia.org/r/121402

This should be deployed to WMF wikis with 1.23wmf21, see https://www.mediawiki.org/wiki/MediaWiki_1.23/Roadmap for the schedule.

Change 124137 had a related patch set uploaded by Brian Wolff:
Make doEditContent call $dbw->rollback() if exception happens

https://gerrit.wikimedia.org/r/124137

(In reply to Gerrit Notification Bot from comment #6)

Change 124137 had a related patch set uploaded by Brian Wolff:
Make doEditContent call $dbw->rollback() if exception happens
https://gerrit.wikimedia.org/r/124137

This patch is related to making certain things more robust, but ultimately this bug is already fixed, so resetting to fixed.

Change 124137 merged by jenkins-bot:
Make doEditContent call $dbw->rollback() if exception happens

https://gerrit.wikimedia.org/r/124137