Bound BagOStuff::lock() RTT estimate for sanity
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 22 Oct 2015 03:14:54 +0000 (20:14 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 22 Oct 2015 03:14:54 +0000 (20:14 -0700)
The timestamp difference might be 0 (or in rare cases, less)

Change-Id: I0298b413df637d9da5ff33c078ad49dadc8a46ce

includes/libs/objectcache/BagOStuff.php

index 5dfec6e..c3c357f 100644 (file)
@@ -328,7 +328,8 @@ abstract class BagOStuff implements LoggerAwareInterface {
                } elseif ( $this->getLastError() || $timeout <= 0 ) {
                        $locked = false; // network partition or non-blocking
                } else {
-                       $uRTT = ceil( 1e6 * ( microtime( true ) - $timestamp ) ); // estimate RTT (us)
+                       // Estimate the RTT (us); use 1ms minimum for sanity
+                       $uRTT = max( 1e3, ceil( 1e6 * ( microtime( true ) - $timestamp ) ) );
                        $sleep = 2 * $uRTT; // rough time to do get()+set()
 
                        $attempts = 0; // failed attempts