Deferred page_touched update via onTransactionIdle.
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 26 Mar 2013 20:08:41 +0000 (13:08 -0700)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 2 Apr 2013 23:35:36 +0000 (23:35 +0000)
* This should reduce deadlocks and lock wait timeouts.

Change-Id: I595bc33d7643e7964d796b1d3da31f7cfab55024

includes/Title.php

index 5ce742c..a40e444 100644 (file)
@@ -4501,23 +4501,30 @@ class Title {
         */
        public function invalidateCache() {
                global $wgMemc;
+
                if ( wfReadOnly() ) {
                        return false;
                }
+
                $dbw = wfGetDB( DB_MASTER );
-               $success = $dbw->update(
-                       'page',
-                       array( 'page_touched' => $dbw->timestamp() ),
-                       $this->pageCond(),
-                       __METHOD__
-               );
+               $conds = $this->pageCond();
+               $dbw->onTransactionIdle( function() use ( $dbw, $conds ) {
+                       $dbw->update(
+                               'page',
+                               array( 'page_touched' => $dbw->timestamp() ),
+                               $conds,
+                               __METHOD__
+                       );
+               } );
                HTMLFileCache::clearFileCache( $this );
 
                // Clear page info.
                $revision = WikiPage::factory( $this )->getRevision();
-               if( $revision !== null ) {
+               if ( $revision !== null ) {
                        $memcKey = wfMemcKey( 'infoaction', $this->getPrefixedText(), $revision->getId() );
-                       $success = $success && $wgMemc->delete( $memcKey );
+                       $success = $wgMemc->delete( $memcKey );
+               } else {
+                       $success = true;
                }
 
                return $success;