Fixed getLagTimes() locking
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 27 Apr 2015 20:14:21 +0000 (13:14 -0700)
committerLegoktm <legoktm.wikipedia@gmail.com>
Mon, 27 Apr 2015 20:19:28 +0000 (20:19 +0000)
* Previously it deleted the value it just cached due to a missing suffix,
  which would lead to connection spam to get the new lag values.

Change-Id: I1040b2b87d3d4ddd7c368291cab87daf4227c2d0

includes/db/LoadMonitor.php
includes/libs/objectcache/BagOStuff.php

index 91840dd..3d853cb 100644 (file)
@@ -115,10 +115,10 @@ class LoadMonitorMySQL implements LoadMonitor {
                }
 
                # Cache key missing or expired
-               if ( $cache->add( "$memcKey:lock", 1, 10 ) ) {
+               if ( $cache->lock( $memcKey, 0, 10 ) ) {
                        # Let this process alone update the cache value
                        $unlocker = new ScopedCallback( function () use ( $cache, $memcKey ) {
-                               $cache->delete( $memcKey );
+                               $cache->unlock( $memcKey );
                        } );
                } elseif ( is_array( $times ) ) {
                        # Could not acquire lock but an old cache exists, so use it
index 5447ee7..a34b265 100644 (file)
@@ -205,7 +205,7 @@ abstract class BagOStuff implements LoggerAwareInterface {
 
        /**
         * @param string $key
-        * @param int $timeout Lock wait timeout [optional]
+        * @param int $timeout Lock wait timeout; 0 for non-blocking [optional]
         * @param int $expiry Lock expiry [optional]
         * @return bool Success
         */