Skip to content

Commit 1e546c8

Browse files
committed
Add README for Lock library, fix issue with lock release, add a comment
1 parent 4ad9c5d commit 1e546c8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
227227
continue;
228228
}
229229

230+
// Note: we acquire the lock here instead of above, as it should be taken by standalone (child) process,
231+
// not by the parent process.
230232
if (!$this->lockManager->setLock(self::LOCK_PREFIX . $groupId, self::LOCK_TIMEOUT)) {
231233
$this->logger->warning(
232234
sprintf(
@@ -277,7 +279,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
277279
$schedule->save();
278280
}
279281

280-
$this->lockManager->releaseLock($groupId);
282+
$this->lockManager->releaseLock(self::LOCK_PREFIX . $groupId);
281283
}
282284
}
283285

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Lock library
2+
3+
Lock library provides mechanism to acquire Magento system-wide lock. Default implementation is based on MySQL locks, where any locks are automatically released on connection close.
4+
5+
The library provides interface *LockManagerInterface* which provides following methods:
6+
* *setLock* - Sets a named lock
7+
* *releaseLock* - Releases a named lock
8+
* *isLocked* - Tests if a named lock exists

0 commit comments

Comments
 (0)