From ddd260ffa4a16ed756e3e3d506d638a9fa30038d Mon Sep 17 00:00:00 2001 From: Dale Davies Date: Thu, 10 Aug 2023 13:42:46 +0100 Subject: [PATCH] MDL-76865 core: Check lock state before attempting to acquire a lock --- cache/classes/loaders.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/classes/loaders.php b/cache/classes/loaders.php index 888f29c3152..3d650feb564 100644 --- a/cache/classes/loaders.php +++ b/cache/classes/loaders.php @@ -608,7 +608,8 @@ class cache implements cache_loader { // store; parent method will have set it to all stores if needed. if ($setaftervalidation) { $lock = null; - if (!empty($this->requirelockingbeforewrite)) { + // Only try to acquire a lock for this cache if we do not already have one. + if (!empty($this->requirelockingbeforewrite) && !$this->check_lock_state($key)) { $lock = $this->acquire_lock($key); } if ($requiredversion === self::VERSION_NONE) {