From 1deb64b12cbc8a608d1b23fa0a43906e53282710 Mon Sep 17 00:00:00 2001 From: Matthieu Aubry Date: Thu, 16 Jan 2020 17:46:53 +1300 Subject: [PATCH] Fix Could not get the lock for ID, when creating a site (#15401) * Lock key start * do not empty key lock Co-authored-by: Thomas Steur --- core/Concurrency/Lock.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/Concurrency/Lock.php b/core/Concurrency/Lock.php index f63bec640a3a..e16b3465cebe 100644 --- a/core/Concurrency/Lock.php +++ b/core/Concurrency/Lock.php @@ -50,11 +50,15 @@ public function getAllAcquiredLockKeys() public function execute($id, $callback) { - if (Common::mb_strlen($id) > self::MAX_KEY_LEN) { + $maxLen = self::MAX_KEY_LEN; + if (!empty($this->lockKeyStart)) { + $maxLen = $maxLen - strlen($this->lockKeyStart); + } + if (Common::mb_strlen($id) > $maxLen) { // Lock key might be too long for DB column, so we hash it but leave the start of the original as well // to make it more readable $md5Len = 32; - $id = Common::mb_substr($id, 0, self::MAX_KEY_LEN - $md5Len - 1) . md5($id); + $id = Common::mb_substr($id, 0, $maxLen - $md5Len - 1) . md5($id); } $i = 0;