From: Aaron Schulz Date: Thu, 6 Aug 2015 23:08:41 +0000 (-0700) Subject: Made BagOStuff::merge() avoid retries on I/O errors X-Git-Tag: 1.31.0-rc.0~10489 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=4065e4d1ab7bb0e1065379d491e3ca050c30ac4d;p=lhc%2Fweb%2Fwiklou.git Made BagOStuff::merge() avoid retries on I/O errors Change-Id: Ia2fd61132322ed3fa8909d60d9f7eb42e39cb443 --- diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index 726c789e65..cc07db4453 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -142,11 +142,17 @@ abstract class BagOStuff implements LoggerAwareInterface { */ protected function mergeViaCas( $key, $callback, $exptime = 0, $attempts = 10 ) { do { + $this->clearLastError(); $casToken = null; // passed by reference $currentValue = $this->get( $key, $casToken ); + if ( $this->getLastError() ) { + return false; // don't spam retries (retry only on races) + } + // Derive the new value from the old value $value = call_user_func( $callback, $this, $key, $currentValue ); + $this->clearLastError(); if ( $value === false ) { $success = true; // do nothing } elseif ( $currentValue === false ) { @@ -156,6 +162,9 @@ abstract class BagOStuff implements LoggerAwareInterface { // Try to update the key, failing if it gets changed in the meantime $success = $this->cas( $casToken, $key, $value, $exptime ); } + if ( $this->getLastError() ) { + return false; // IO error; don't spam retries + } } while ( !$success && --$attempts ); return $success; @@ -189,14 +198,17 @@ abstract class BagOStuff implements LoggerAwareInterface { return false; } + $this->clearLastError(); $currentValue = $this->get( $key ); - // Derive the new value from the old value - $value = call_user_func( $callback, $this, $key, $currentValue ); + if ( !$this->getLastError() ) { + // Derive the new value from the old value + $value = call_user_func( $callback, $this, $key, $currentValue ); - if ( $value === false ) { - $success = true; // do nothing - } else { - $success = $this->set( $key, $value, $exptime ); // set the new value + if ( $value === false ) { + $success = true; // do nothing + } else { + $success = $this->set( $key, $value, $exptime ); // set the new value + } } if ( !$this->unlock( $key ) ) {