From: Aaron Schulz Date: Thu, 18 Oct 2018 18:42:27 +0000 (-0700) Subject: objectcache: avoid using heavily time-drifted microtime() values in WAN cache X-Git-Tag: 1.34.0-rc.0~3723^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/Dunav?a=commitdiff_plain;h=d2c2bf6553c07ea6dd089efd1c7ba62826eea009;p=lhc%2Fweb%2Fwiklou.git objectcache: avoid using heavily time-drifted microtime() values in WAN cache Change-Id: Ifcb9e4b4a1d5adfdaaa6ea505e34956516b871de --- diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 3af820b883..e7586cfe02 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -2225,7 +2225,17 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @codeCoverageIgnore */ protected function getCurrentTime() { - return $this->wallClockOverride ?: microtime( true ); + if ( $this->wallClockOverride ) { + return $this->wallClockOverride; + } + + $clockTime = (float)time(); // call this first + // microtime() uses an initial gettimeofday() call added to usage clocks. + // This can severely drift from time() and the microtime() value of other threads + // due to undercounting of the amount of time elapsed. Instead of seeing the current + // time as being in the past, use the value of time(). This avoids setting cache values + // that will immediately be seen as expired and possibly cause stampedes. + return max( microtime( true ), $clockTime ); } /**