Try to reduce stale cache updates in User::saveSettings()
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 16 Apr 2015 03:34:51 +0000 (20:34 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 16 Apr 2015 03:34:51 +0000 (20:34 -0700)
Bug: T95839
Change-Id: I4dc87697448b833ea575cbb3e05c92c7160d03f9

includes/User.php

index f862953..59d5c03 100644 (file)
@@ -3647,6 +3647,14 @@ class User implements IDBAccessObject {
                Hooks::run( 'UserSaveSettings', array( $this ) );
                $this->clearSharedCache();
                $this->getUserPage()->invalidateCache();
+
+               // T95839: clear the cache again post-commit to reduce race conditions
+               // where stale values are written back to the cache by other threads.
+               // Note: this *still* doesn't deal with REPEATABLE-READ snapshot lag...
+               $that = $this;
+               $dbw->onTransactionIdle( function() use ( $that ) {
+                       $that->clearSharedCache();
+               } );
        }
 
        /**