From 70bf85d46262f693d62c1f10acd6069265013334 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 2 Feb 2019 18:13:17 -0800 Subject: [PATCH] objectcache: avoid duplicate set() calls with lockTSE when no value is in cache Each thread will still run the callback, but only one will save the value back Bug: T203786 Change-Id: Idc4738aa005cc44ec0f1adc6dcf2e3f87d0c9480 --- includes/libs/objectcache/WANObjectCache.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 6e8d266e14..88f87f857e 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -1334,7 +1334,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $this->setInterimValue( $key, $wrapped, $tempTTL ); } - if ( $valueIsCacheable ) { + // Save the value unless a mutex-winning thread is already expected to do that + if ( $valueIsCacheable && ( !$useMutex || $lockAcquired ) ) { $setOpts['lockTSE'] = $lockTSE; $setOpts['staleTTL'] = $staleTTL; // Use best known "since" timestamp if not provided -- 2.20.1