Skip to content

Commit 1cdae60

Browse files
committed
MC-6273: Mysql url_rewrite select make on product view page 170+ times per request
- fixes after CR
1 parent 64643ab commit 1cdae60

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

app/code/Magento/Config/App/Config/Type/System.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,13 @@ private function readData(): array
389389
public function clean()
390390
{
391391
$this->data = [];
392-
$this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]);
392+
$cleanAction = function () {
393+
$this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]);
394+
};
395+
396+
$this->lockQuery->lockedCleanData(
397+
self::$lockName,
398+
$cleanAction
399+
);
393400
}
394401
}

lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,25 @@ public function lockedLoadData(
9292

9393
return $cachedData;
9494
}
95+
96+
/**
97+
* Clean data.
98+
*
99+
* @param string $lockName
100+
* @param callable $dataCleaner
101+
* @return void
102+
*/
103+
public function lockedCleanData(string $lockName, callable $dataCleaner)
104+
{
105+
while ($this->locker->isLocked($lockName)) {
106+
usleep($this->delayTimeout * 1000);
107+
}
108+
try {
109+
if ($this->locker->lock($lockName, $this->lockTimeout / 1000)) {
110+
$dataCleaner();
111+
}
112+
} finally {
113+
$this->locker->unlock($lockName);
114+
}
115+
}
95116
}

0 commit comments

Comments
 (0)