Aaron Schulz has uploaded a new change for review.

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

Change subject: Reduce CAS errors due to concurrent web requests by a user
......................................................................

Reduce CAS errors due to concurrent web requests by a user

Bug: T95839
Change-Id: If4013f34a39c451fe0a75b557a8f2c5316c57bdc
---
M BetaFeaturesHooks.php
1 file changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures 
refs/changes/67/259967/1

diff --git a/BetaFeaturesHooks.php b/BetaFeaturesHooks.php
index f3d1f8b..2f262d8 100644
--- a/BetaFeaturesHooks.php
+++ b/BetaFeaturesHooks.php
@@ -281,10 +281,17 @@
                }
 
                if ( $saveUser ) {
-                       // Save the preferences to the DB post-send
-                       DeferredUpdates::addCallableUpdate( function() use ( 
$user ) {
-                               $user->saveSettings();
-                       } );
+                       $cache = ObjectCache::getLocalClusterInstance();
+                       $key = $cache->makeKey( __CLASS__, 'prefs-update', 
$user->getId() );
+                       // T95839: If concurrent requests pile on (e.g. 
multiple tabs), only let one
+                       // thread bother doing these updates. This avoids 
pointless error log spam.
+                       if ( $cache->lock( $key, 0, $cache::TTL_MINUTE ) ) {
+                               // Save the preferences to the DB post-send
+                               DeferredUpdates::addCallableUpdate( function() 
use ( $user, $cache, $key ) {
+                                       $user->saveSettings();
+                                       $cache->unlock( $key );
+                               } );
+                       }
                }
 
                return true;

-- 
To view, visit https://gerrit.wikimedia.org/r/259967
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4013f34a39c451fe0a75b557a8f2c5316c57bdc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to