Page MenuHomePhabricator

categories are broken on sqlite as a result of calling beginMasterChanges() prior to the job insert being comitted
Closed, DeclinedPublic

Description

On sqlite (I have not tested any other dbs) category updates are currently broken.

What currently seems to happen (on page save):

  • There's a deferred update to enqueue a RefreshLinksPrioritized
  • There is a deferred CallableUpdate that comes next
    • This update is wrapped around $lbFactory->beginMasterChanges( $fnameTrxOwner ) and $lbFactory->commitMasterChanges( $fnameTrxOwner )
    • LBFactory::beginMasterChanges calls IDatabase::flushSnapshot (via LoadBalancer::beginMasterChanges) on the master connections. LoadBalancer::beginMasterChanges has comment "Clear any empty transactions (no writes/callbacks) from the implicit round", which to me implies that it thinks its only flushing snapshots in the case that no writes have happened in this commit. Meanwhile flushSnapshot will throw an exception if any writes are pending.
  • Since the job insertion wrote some pending stuff to db, an exception is thrown from flushSnapshot. This results in DeferredUpdates::runUpdate calling MWExceptionHandler::rollbackMasterChangesAndLog( $e ) rolling back all the deferred updates so far.
  • The rollback causes the refrshLinks job to not be inserted.
  • Categories never get populated.

Based on a report by Grobo in #mediawiki irc channel.