Reduce deadlocks adding log rows to the RC table on delete
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 10 Jun 2014 20:25:34 +0000 (13:25 -0700)
committerOri.livneh <ori@wikimedia.org>
Wed, 11 Jun 2014 18:41:13 +0000 (18:41 +0000)
bug: 56776
Change-Id: Ic75530b25f3fa5668019c76ce59a1dda2768f389

includes/WikiPage.php

index 52c5ccc..cedbcf9 100644 (file)
@@ -2874,7 +2874,11 @@ class WikiPage implements Page, IDBAccessObject {
                $logEntry->setTarget( $logTitle );
                $logEntry->setComment( $reason );
                $logid = $logEntry->insert();
-               $logEntry->publish( $logid );
+
+               $dbw->onTransactionPreCommitOrIdle( function() use ( $dbw, $logEntry, $logid ) {
+                       // Bug 56776: avoid deadlocks (especially from FileDeleteForm)
+                       $logEntry->publish( $logid );
+               } );
 
                if ( $commit ) {
                        $dbw->commit( __METHOD__ );